-> i have attached my table image
-> morning pending task update the evening user
->please send the update query Stored Procedure
its my table
ID name task Shift Status
1 Selastin DragAndDrop Morning Pending
2 Rasim CopyPaste Morning Pending
3 Robin updateAntivirus Evening
4 Dileep insertTask Evening
5 Binu Automaticupdation Evening
please send the update query Stored Procedure
SAMPLEOUTPUT
ID name task Shift Status
1 Robin DragAndDrop Evening Pending
2 Dileep CopyPaste Evening pending
3 Robin updateAntivirus Evening
4 Dileep insertTask Evening
5 Binu Automaticupdation Evening
Loading
Khan Abrar AhmedPosted May 28, 2014, 6:50 AM
selastin belPosted May 28, 2014, 6:48 AM
Khan Abrar AhmedPosted May 28, 2014, 4:44 AM
DECLARE @table AS TABLE (ID INT,NAME VARCHAR(64),task VARCHAR(64),[Shift] VARCHAR(64),[Status] VARCHAR(64) NULL)
DECLARE @tablePending AS TABLE (ID INT,NAME VARCHAR(64),task VARCHAR(64),[Shift] VARCHAR(64),[Status] VARCHAR(64) NULL)
INSERT INTO @table
( ID, NAME, task, Shift, Status )
VALUES
(1 , 'Selastin' , 'DragAndDrop' , 'Morning' , 'Pending' ) ,
(2 , 'Rasim' , 'CopyPaste' , 'Morning', 'Pending' ) ,
(3 , 'Robin' , 'updateAntivirus' , 'Evening',NULL),
(4 , 'Dileep' , 'insertTask' , 'Evening',NULL),
(5 , 'Binu', 'Automaticupdation' , 'Evening',null)
INSERT INTO @tablePending
SELECT * FROM @table WHERE Shift='Evening'
UPDATE @table SET NAME=tp.NAME,Shift=tp.Shift
From @tablePending AS tp
LEFT JOIN @table AS t ON t.Status='Pending'
SELECT * FROM @table