当前位置: 代码迷 >> Sql Server >> SQL 插入语句格式化解决办法
  详细解决方案

SQL 插入语句格式化解决办法

热度:65   发布时间:2016-04-24 18:42:19.0
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
  相关解决方案