我需要为deleteQuestion这个select查询返回的每个元素执行过程:
select id from questions where Stuff = @Stuff
execute deleteQuestion id
Run Code Online (Sandbox Code Playgroud)
就像是:
execute deleteQuestion each(select id fom questions where Stuff = @Stuff)
谁知道怎么样?
使用游标:
DECLARE @Id INT
DECLARE your_cursor CURSOR FOR
SELECT id from questions where Stuff = @Stuff
OPEN your_cursor
FETCH NEXT FROM your_cursor
INTO @Id
WHILE @@FETCH_STATUS = 0
BEGIN
execute deleteQuestion @Id
FETCH NEXT FROM your_cursor
INTO @Id
END
CLOSE your_cursor
DEALLOCATE your_cursor
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
110 次 |
| 最近记录: |