SQL Update if parameter is not null or empty

not sure what you are trying to achieve if it is blank, but I would try using IsNull() I don’t think there is an IsBlank(), but it shouldn’t be too hard to write yourself

Using just IsNull your query would look something like…

Update [Users]
set    FirstName = IsNull(@FirstName, FirstName),
       City = IsNull(@City, City)
       ....
Where  ...

this will Update the row with the param value if they are NOT null, otherwise update it to itself aka change nothing.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)