我希望得到这样的结果啊select xx,xx,
replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','') AS strTime
xx xx strTime
1 1 20070403111111 --年月日小时分钟秒
2 2 20070403111112 --年月日小时分钟秒
3 3 20070403111113 --年月日小时分钟秒就是希望strTime的时间能不一样啊。。秒钟或者分钟不要重复啊第二个问题
怎能精确到毫秒呢?也按照上面的格式输出
replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','') AS strTime
xx xx strTime
1 1 20070403111111 --年月日小时分钟秒
2 2 20070403111112 --年月日小时分钟秒
3 3 20070403111113 --年月日小时分钟秒就是希望strTime的时间能不一样啊。。秒钟或者分钟不要重复啊第二个问题
怎能精确到毫秒呢?也按照上面的格式输出
insert into #t select 2,2
insert into #t select 3,3
select
f1,
f2,
replace(replace(replace(CONVERT(varchar, dateadd(s,f1,getdate()), 120 ),'-',''),' ',''),':','') AS t
from #t
drop table #t
这个p缺省值不是6吗。能指定到(0到9)。所以小数秒精确到6位是没问题的。
insert into #t select 2,2
insert into #t select 3,3
select
f1,
f2,
replace(replace(replace(replace(replace(CONVERT(varchar, dateadd(s,f1,getdate()),126 ),'-',''),' ',''),':',''),'T',''),'.','') AS t
from #t
drop table #t