datatime的拼接
tsrq (datetime) tssj(char(8))
2008-01-01 00:00:0009:26:47
2008-01-01 00:00:0009:49:23
2008-01-01 00:00:0011:16:53
现在表T字段tsrq(类型datetime)里面只有日期没有具体时间(时间都是 00:00:00),另一个字段tssj有具体时间09:26:47,类型是char(8))。如果把tssj时间拼到tsrq里面。
[最优解释]
CREATE TABLE test (tsrq DATETIME, tssj char(8))
INSERT INTO test
SELECT '2008-01-01 00:00:00', '09:26:47'
UNION ALL
SELECT '2008-01-01 00:00:00', '09:49:23'
UNION ALL
SELECT '2008-01-01 00:00:00', '11:16:53'
SELECT CONVERT(VARCHAR(10),CONVERT (DATE,tsrq))+' '+CONVERT(VARCHAR(10),tssj) FROM test
/*
---------------------
2008-01-01 09:26:47
2008-01-01 09:49:23
2008-01-01 11:16:53
*/
update a
set tsrs=convert(varchar(10),convert (date,tsrq))+' '+convert(varchar(10),tssj)
from tableName a,tableName b where a.主键=b.主键
--两个tableName都是你的那个表
update #A set tsrq=tsrq+tssj-- from T
select tsrq+tssj from T
update T set tsrq=tsrq+tssj
select tsrq+convert(datetime,tssj) from tb