lundi 18 mai 2015

MS SQL IF with a select value

How do I state - If a field in my table is NULL only then do the update.

For example:

IF customer_day_phone (from my #invoice table) where id_key = @id_key -matches my parameter - is null. Then run my update.

But i'll have multiple rows coming back and I only want to update those who are NULL.

IF select customer_day_phone from #invoice where id_key = @id_key and  customer_day_phone is null 
BEGIN
...
END 

Thank you.

Aucun commentaire:

Enregistrer un commentaire