下面的脚本得到“DECLARE CURSOR must be the only statement in a query batch”。请问这是怎么回事?
此脚本保存在一个文件中,并从isql客户端执行。
DECLARE c1 cursor FOR
select sql_query from tempdb..M3_Checks_Query
GO
DECLARE @sql_query text
OPEN c1
FETCH c1 into @sql_query --@check_id , @sql_query, @base_table, @run_flag
WHILE @@sqlstatus = 0
BEGIN
print "test"
FETCH c1 into @sql_query
END
CLOSE c1
DEALLOCATE c1