游标定义为datetime类型出现的问题
declare @time datetime
declare span cursor for select curdate from curgpsinfo
open span
fetch next from span into @time
begin
print @time
fetch next from span into @time
end
close span
deallocate span
curdate字段也是datetime类型的
但是数据库里面是这样的
2007-08-24 16:19:09.000
而我print出来却是
08 24 2007 4:19PM
秒的信息丢失了
如何才能按照原样打印出来啊?
[解决办法]
try
declare @time datetime
declare span cursor for select curdate from curgpsinfo
open span
fetch next from span into @time
begin
print Convert(Varchar, @time, 120)
fetch next from span into @time
end
close span
deallocate span