循环的sql指令怎么写
我有一数据表!
table1
里面有多条记录
其中有一字段v1
v1里面保存的是字段计算指令
我想实现打开数据表table1
然后循环读取v1
执行v1的内容
select * from table1
while ....
@v1=select v1 from table
exec(@v1)
.....
完整的sql应该怎么写
[解决办法]
declare @v1 varchar(2000)declare curtable1 cursor for select v1from table1open curtable1fetch next from curtable1 into @v1while @@fetch_status = 0begin exec(@v1) fetch next from curtable1 into @v1endclose curtable1deallocate curtable1