SQL inserting value of a specific column under multple case
- by Lo Wai Lun
Suppose I have got a table which I have to insert the description of the contract under different keys of contract.
But when executing, there is a n error near then
Is there any limitation of using syntax set ?
The below is my SQL
declare @i int, @j v nvarchar(MAX)
set @i = 1
while (@i<=8)
begin
set @j = case when @i = 1 then 'CR' when @i = 2 then 'Facebook' else 'N/A' end
INSERT INTO CostNature (CNKey, CNNDescription) VALUES (@i , @j );
set @i = @i + 1
end