当前位置:Gxlcms > 数据库问题 > SQL时间转换脚本查询列表

SQL时间转换脚本查询列表

时间:2021-07-01 10:21:17 帮助过:1人阅读

procedure up_ConvertTime as begin declare @i int,@str varchar(max),@error int if(OBJECT_ID(tempdb..#t) is not null) drop table #t Create table #t(nID int ,dTime varchar(50) ) set @i=0 while(@i<=131) begin--while if(@i in(
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14, 21,22,23,24,25,101,102,103,104,105, 106,107,108,109,110,111,112,113,114, 121,127,131)) begin if(@i=0) set @str=select 输出格式=CONVERT(varchar,GETDATE(),+convert(varchar,@i)+),+参数值=+convert(varchar,@i) else if(@i>0) set @str=@str+ union all +select CONVERT(varchar,GETDATE(),+convert(varchar,@i)+)+,+convert(varchar,@i) end set @i=@i+1 end--while print @str execute(@str) if(OBJECT_ID(tempdb..#t) is not null) drop table #t end

执行:exec up_ConvertTime

输出格式:技术分享

比如现在需要的格式为30行的格式

select convert(varchar,getdate(),110)

 

以上为本人亲测,如有疑问,烦请大家纠正,谢谢。

SQL时间转换脚本查询列表

标签:

人气教程排行