我正在尝试在SQL Server中创建一个表达式,它将检查某个列是否为null,如果为null,则设置一个新的GUID号。
这是我的代码:
select
isnull((select Guid
from therapists
where username = 'ido' and password = 'ido'),
(update therapists
set guid = NEWID()
where username = 'ido' and password = 'ido'))
答案 0 :(得分:1)
你可以试试这个:
UPDATE therapists SET guid = NEWID()
WHERE username = 'ido'
AND password = 'ido'
AND guid IS NULL;