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 spancurdate字段也是datetime类型的
但是数据库里面是这样的
2007-08-24 16:19:09.000
而我print出来却是
08 24 2007  4:19PM秒的信息丢失了
如何才能按照原样打印出来啊?

解决方案 »

  1.   

    trydeclare @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
      

  2.   

    或者declare @time datetime
    declare span cursor for select curdate from curgpsinfo
    open span
    fetch next from span into @time
    begin
    print Convert(Varchar, @time, 121)
    fetch next from span into @time
    end
    close span
    deallocate span