April 18, 2017 at 5:30 am
Hi ,
I have a following update query and I want to select the updated data from "master table" and insert into a different table called "MainMaster"
Could anyone please help on this?
Update master
set checkin ='N'
where nos IN (SELECT B.nos FROM master B
INNER JOIN employee C ON C.id = B.id
where B.size = 0
AND B.checkin ='Y')
T
April 18, 2017 at 5:42 am
Use an OUTPUT clause.
John
April 18, 2017 at 5:42 am
Perhaps:UPDATE [master]
SET checkin ='N'
OUTPUT inserted.* --You may need to adjust the * to the correct Column names if your tables do not exactly match
INTO MainMaster
WHERE nos IN (SELECT B.nos
FROM [master] B
INNER JOIN employee C ON C.id = B.id
WHERE B.size = 0
AND B.checkin ='Y');
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
April 18, 2017 at 7:16 am
Thom A - Tuesday, April 18, 2017 5:42 AMPerhaps:UPDATE [master]
SET checkin ='N'
OUTPUT inserted.* --You may need to adjust the * to the correct Column names if your tables do not exactly match
INTO MainMaster
WHERE nos IN (SELECT B.nos
FROM [master] B
INNER JOIN employee C ON C.id = B.id
WHERE B.size = 0
AND B.checkin ='Y');
Thank you , it worked out :)!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply