How do I make this query first find all professors开发者_开发问答 whose picture IS NULL and THEN update with a new value for column 'picpath'
I have:
SELECT * FROM Professor
WHERE picpath IS NULL;
Is it possible to form this all in a subquery perhaps? Can someone help
How about, you could do
update professor set picpath=<newvaluehere> where picpath is null
Using SQL Server's OUTPUT
clause (MSSQL208 and above) you can kinds of do the same but the other way around i.e. UPDATE
then SELECT
the affected rows e.g.
UPDATE professor
SET picpath = 'C:\'
OUTPUT inserted.*
WHERE picpath IS NULL;
精彩评论