Reputation: 6587
I am newbie to SQL queries so sorry for this basic question.
I want to insert values into a table where column's value is null
I tried following
INSERT INTO SystemUsers(FilePath)
If @FilePath IS Null
values('C:\Users\Developer\Desktop\MvcApplication8\MvcApplication8\App_Data\Uploads\Lighthouse.jpg')
and
INSERT INTO SystemUsers(FilePath)
where FilePath IS Null
values('C:\Users\Developer\Desktop\MvcApplication8\MvcApplication8\App_Data\Uploads\Lighthouse.jpg')
But that didn't work, how can I insert default values in a column whether column's values are null?
Upvotes: 0
Views: 1021
Reputation: 69524
UPDATE SystemUsers
SET FilePath = 'C:\Users\Developer\Desktop\MvcApplication8\MvcApplication8\App_Data\Uploads\Lighthouse.jpg'
WHERE FilePath is null
Where clause normaly comes after the operation you are doing.
Upvotes: 0
Reputation: 4445
Maybe what you want is the UPDATE command and not the insert something like this
UPDATE SystemUsers
SET FilePath = 'C:\Users\Developer\Desktop\MvcApplication8\MvcApplication8\App_Data\Uploads\Lighthouse.jpg'
WHERE FilePath is null
Upvotes: 9