日期:2014-05-17 浏览次数:20611 次
Alter procedure createdatelog
as
begin
create table #tb_kaoqin(userid nvarchar(50),username nvarchar(50))
declare @starttime datetime
declare @endtime datetime
declare @settime datetime
declare @sql varchar(100)
set @starttime='2014-01-01'
set @settime='2014-01-01'
set @endtime='2014-12-31'
while @starttime <@endtime
begin
if @settime>=@endtime
return
set @settime=dateadd(dd,1,@settime)
set @sql='alter table #tb_kaoqin add ['+ Convert(varchar(10), @settime,120)+'] nvarchar(10)'
print @sql
exec (@sql)
select * from #tb_kaoqin
end
end
go
exec createdatelog
create procedure createdatelog
as
begin
create table #tb_kaoqin(userid nvarchar(50),username nvarchar(50))
declare @starttime datetime
declare @endtime datetime
declare @settime datetime
declare @sql varchar(100)
set @starttime='2014-01-01'
set @settime='2014-01-01'
set @endtime='2014-12-31'
while @settime <@endtime
begin
--if @settime>=@endtime
--return
set @settime=dateadd(dd,1,@settime)
set @sql='alter table #tb_kaoqin add ['+ Convert(varchar(10), @settime,120)+'] nvarchar(10)'
print @sql
exec (@sql)
select * from #tb_kaoqin
end
end
go
exec createdatelog