【www.gdgbn.com--php与数据库】

sql convert() 字符串转整型 日期 字符型

转换成日期写法

convert(data_type(length),data_to_be_converted,style)

实例

select convert(varchar(30),getdate(),101) now


转换成整型

convert( int, column )

如我要把手机号转换成整型,

select convert(int(8),mo) moint

会报错,为什么,下面我们再看一下实例。

select convert(bigint,mo) moint


这样就正确了,原因是数字类型不正确,手机号是11位,而int型只能是8位,自然

会出错了。

本文来源:http://www.gdgbn.com/jiaocheng/28777/