日期:2014-05-17  浏览次数:20485 次

SQL 插入语句格式化
想把A表中的数据插入到B表中,但是A表中的某个字段的类型为datetime/smalldatetime,插入到B表中时,转换成date类型。也就是将A表中的数据插入到B表中时,只将A表中的日期插入到B表,不需要时间。
SQL语句怎么写。

------解决方案--------------------
转化一下类型就可以:

insert into b(字段)
select CONVERT(varchar(10),字段,120)
from A

------解决方案--------------------
insert into b(列名)
select convert(date,列名)
from a