如果建立cursor在两个字段上,而对一个变量赋值,会抱错么?
比如说:
declare @id int
create cur1 cursor
for select id,name from student
open cur1
fetch next from cur1 into @id /* in cur1 there are two column, then fetch them into only one variable, how it will be? */
close cur1
deallocate cur1
比如说:
declare @id int
create cur1 cursor
for select id,name from student
open cur1
fetch next from cur1 into @id /* in cur1 there are two column, then fetch them into only one variable, how it will be? */
close cur1
deallocate cur1
Cursorfetch: 在 INTO 列表中声明的变量数目必须与所选择的列数目匹配。declare @id int
create cur1 cursor -- declare cur1 cursor
for select id,name from student
open cur1
fetch next from cur1 into @id /* in cur1 there are two column, then fetch them into only one variable, how it will be? */
close cur1
deallocate cur1
数量要对应,确实要一个变量接收,应在声明时只给一个,或用两个字段组合成一个查询字段