SQL SERVER 建临时表、循环插入数据、游标遍历数据库

来源:互联网 发布:金山数据大师破解版 编辑:程序博客网 时间:2024/06/06 16:25
create table #tmp (id int)  --建立临时数据表declare @x int  --循环插入数据set @x=1while @x<=10begininsert into #tmp values(@x)set @x=@x+1end--建立游标 遍历数据库declare tmpCursor CURSOR for  select * from #tmpopen tmpCursordeclare @id intfetch next from tmpCursor into @idwhile  @@FETCH_STATUS =0beginprint @idfetch next from tmpCursor into @idend

0 0