輸入:
declare @a intset @a = 0while @a<=10000 begin begin try print 'Convert(varchar,Getdate(),' + cast(@a as varchar) + ') -> ' + Convert(varchar, Getdate() , cast(@a as int)) end try begin catch --print cast(@a as varchar) + ': Error' end catch set @a = @a+1end
輸出:
Convert(varchar,Getdate(),0) -> 06 14 2013 2:53PMConvert(varchar,Getdate(),1) -> 06/14/13Convert(varchar,Getdate(),2) -> 13.06.14Convert(varchar,Getdate(),3) -> 14/06/13Convert(varchar,Getdate(),4) -> 14.06.13Convert(varchar,Getdate(),5) -> 14-06-13Convert(varchar,Getdate(),6) -> 14 06 13Convert(varchar,Getdate(),7) -> 06 14, 13Convert(varchar,Getdate(),8) -> 14:53:16Convert(varchar,Getdate(),9) -> 06 14 2013 2:53:16:167PMConvert(varchar,Getdate(),10) -> 06-14-13Convert(varchar,Getdate(),11) -> 13/06/14Convert(varchar,Getdate(),12) -> 130614Convert(varchar,Getdate(),13) -> 14 06 2013 14:53:16:167Convert(varchar,Getdate(),14) -> 14:53:16:167Convert(varchar,Getdate(),20) -> 2013-06-14 14:53:16Convert(varchar,Getdate(),21) -> 2013-06-14 14:53:16.167Convert(varchar,Getdate(),22) -> 06/14/13 2:53:16 PMConvert(varchar,Getdate(),23) -> 2013-06-14Convert(varchar,Getdate(),24) -> 14:53:16Convert(varchar,Getdate(),25) -> 2013-06-14 14:53:16.167Convert(varchar,Getdate(),100) -> 06 14 2013 2:53PMConvert(varchar,Getdate(),101) -> 06/14/2013Convert(varchar,Getdate(),102) -> 2013.06.14Convert(varchar,Getdate(),103) -> 14/06/2013Convert(varchar,Getdate(),104) -> 14.06.2013Convert(varchar,Getdate(),105) -> 14-06-2013Convert(varchar,Getdate(),106) -> 14 06 2013Convert(varchar,Getdate(),107) -> 06 14, 2013Convert(varchar,Getdate(),108) -> 14:53:16Convert(varchar,Getdate(),109) -> 06 14 2013 2:53:16:170PMConvert(varchar,Getdate(),110) -> 06-14-2013Convert(varchar,Getdate(),111) -> 2013/06/14Convert(varchar,Getdate(),112) -> 20130614Convert(varchar,Getdate(),113) -> 14 06 2013 14:53:16:190Convert(varchar,Getdate(),114) -> 14:53:16:190Convert(varchar,Getdate(),120) -> 2013-06-14 14:53:16Convert(varchar,Getdate(),121) -> 2013-06-14 14:53:16.190Convert(varchar,Getdate(),126) -> 2013-06-14T14:53:16.190Convert(varchar,Getdate(),127) -> 2013-06-14T14:53:16.190Convert(varchar,Getdate(),130) -> 6 ????? 1434 2:53:16:190PMConvert(varchar,Getdate(),131) -> 6/08/1434 2:53:16:190PM