sqlserver2008中cast和convert函数的使用

来源:互联网 发布:手机声卡软件下载 编辑:程序博客网 时间:2024/04/28 20:28

sqlserver2008中的cast和convert:


      将某种数据类型的表达式显式转换为另一种数据类型。

      CAST 和 CONVERT 提供相似的功能。


       语法:

使用 CAST:CAST ( expression AS data_type )

使用 CONVERT:CONVERT (data_type[(length)], expression [, style])

 

实例:

@intType int

cast(@intType as nvarchar(100))

convert(nvarchar(100),@intType)