I have a single table like
createCREATE tableTABLE Mytable (ID int identity, Name nvarchar(10));
GO
INSERT INTO MyTable (Name) VALUES ('test1');
INSERT INTO MyTable (Name) VALUES ('test2');
GO
ALTER TABLE MyTable ADD CONSTRAINT DF_Name DEFAULT('test') FOR NameName;
Now I want to update my Name column like this:
Update MyTable
set name = case ID when 1 then DEFAULT ENDEND;
But I am getting this error:
Incorrect syntax near the keyword 'DEFAULT'
How can I use UPDATEUPDATE
with DEFAULTDEFAULT
statement in CASEthe CASE
clause?
I am using SQL Server 2014.