我想检查row2的值是否为空,然后将同一记录的row1的值复制到row2
我使用while循环检查是否为空,然后复制值
Declare @val varchar(255)
Select @val = row2 from student While(@val IS NULL)
Begin
Update student Set row2 = (select row1 from student)
End
Go
有子查询错误不能使用=,<,>
答案 0 :(得分:1)
您想要做这样的事情:
update student
set row2 = row1
where row2 is null ;
您的问题非常令人困惑,因为row1
和row2
是列的非常奇怪的名称。
答案 1 :(得分:0)
您可以使用test.jsp
。这样,如果coalesce
的值为null,则处理第二个参数(row2
)。顺便说一下,使用row1
,col1
代替2
,row 1
更适合列名,
2
要申请整个数据集,应删除过滤器Update student
Set row2 = coalesce(row2,row1)
Where id = @sid -- individual student ID
。