convert函数 (oracle和sqlserver)

1.在oracle中,一般是把一个字符串从一种编码类型转换成另一种编码类型

http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/functions023.htm#sthref1160

CONVERT

Syntax
convert::=
convert
CONVERT(char, dest_char_set[, source_char_set ])
Purpose

CONVERT converts a character string from one character set to another. The datatype of the returned value is VARCHAR2.

  • The char argument is the value to be converted. It can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB.

  • The dest_char_set argument is the name of the character set to which char is converted.

  • The source_char_set argument is the name of the character set in which char is stored in the database. The default value is the database character set.

Both the destination and source character set arguments can be either literals or columns containing the name of the character set.

For complete correspondence in character conversion, it is essential that the destination character set contains a representation of all the characters defined in the source character set. Where a character does not exist in the destination character set, a replacement character appears. Replacement characters can be defined as part of a character set definition.

Examples

The following example illustrates character set conversion by converting a Latin-1 string to ASCII. The result is the same as importing the same string from a WE8ISO8859P1 database to a US7ASCII database.

SELECT CONVERT('Ä Ê Í Ó Ø A B C D E ', 'US7ASCII', 'WE8ISO8859P1') 
   FROM DUAL; 

CONVERT('ÄÊÍÓØABCDE' 
--------------------- 
A E I ? ? A B C D E ? 

Common character sets include:

  • US7ASCII: US 7-bit ASCII character set

  • WE8DEC: West European 8-bit character set

  • F7DEC: DEC French 7-bit character set

  • WE8EBCDIC500: IBM West European EBCDIC Code Page 500

  • WE8ISO8859P1: ISO 8859-1 West European 8-bit character set

  • UTF8: Unicode 3.0 UTF-8 Universal character set, CESU-8 compliant

  • AL32UTF8: Unicode 3.1 UTF-8 Universal character set

 

----------------------------------------------------------------------------------------

2.SQLSERVER

http://gjbxx110.blog.51cto.com/794841/297007

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值