列出所有DateTime格式
当使用SQL Server的DateTime时候,我经常忘记DateTime参数具体格式。当发生这种情况,我在SQL Server Management Studio中的使用下面代码片段,巧妙地列出了所有可能的
declare @Loop int
set @Loop = -1
declare @table table
( [Date] nvarchar(50) not null, [Param] int not null
)
while @Loop <= 150
begin
set @Loop = @Loop + 1
begin try
insert into @table
select convert(nvarchar, getdate(), @Loop), @Loop
end
try
begin
catch
continue
end
catch
end
select * from @table
set @Loop = -1
declare @table table
( [Date] nvarchar(50) not null, [Param] int not null
)
while @Loop <= 150
begin
set @Loop = @Loop + 1
begin try
insert into @table
select convert(nvarchar, getdate(), @Loop), @Loop
end
try
begin
catch
continue
end
catch
end
select * from @table
posted on 2010-03-30 09:38 kaixingirl 阅读(342) 评论(1) 编辑 收藏 举报