Since a variable can only store a single value.This code throws an error.
Objective: If a certain value isnt there in the other table. Add that value in the table plus other columns.
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Code is here as follows:
declare @something as varchar(1000)
set @something = (select col1 from d)
while @something not in (select distinct col1 from c)
begin
insert into c
(x,y,z)
values
(@something, y, z)
break
end
UPDATE: Found a solution, used an if statement instead.
BREAKin yourWHILEthat isn't conditional? This would only loop once, making theWHILEpointless (not that you need aWHILEanyway)l.