I have a stored procedure to load the data from one table to another table.
i need to set the column value of the destination table based on the two values of the select statement, some thing like the below example.
insert into table table_name
( value1, value 2,value 3)
select (value 1,value2 ,
case value3
when value1 = 'somevalue' &&* value2 = 'somevalue'
then 'x'
else 'y'
End
from table_name.
can any one help me to find out how to update the a column in based on the two previous column values in the same select query?
i have tried with the below sample example to understand but it was failed to parse.
INSERT INTO HumanResources.departmentcopy
( DepartmentID,GroupName,Name,temp)
SELECT DepartmentID,GroupName,Name,
CASE temp
WHEN DepartmentID = 1 && Name = 'Engineering and Research'
THEN 'sucessful'
ELSE 'unsucessful'
END
FROM HumanResources.department
Help me on this!!
thanks, Venkat