April 30, 2008 at 4:27 am
Hi..
I had problem in updating a table ...
My query is suppose there is table like
EMP_ID Comp_ID
100 1234
100 2345
here for same employee comp_id is different..now i am fetching updated value from SAP..so if COMP_ID will get changed..
say..
EMP_ID Comp_ID
100 4567
100 9876
so how should i write stored procedure so that distinct value of same EMP_ID will get updated...
Pls reply...
April 30, 2008 at 6:06 am
svhanda (4/30/2008)
Hi..I had problem in updating a table ...
My query is suppose there is table like
EMP_ID Comp_ID
100 1234
100 2345
here for same employee comp_id is different..now i am fetching updated value from SAP..so if COMP_ID will get changed..
say..
EMP_ID Comp_ID
100 4567
100 9876
so how should i write stored procedure so that distinct value of same EMP_ID will get updated...
Pls reply...
Maybe I'm confused, but
UPDATE TableName
SET Comp_Id = 4567
WHERE Comp_Id = 1234
AND Emp_Id = 100
And to make it a proc:
CREATE PROCEDURE UpdateTableName
(@EmpId int
,@NewCompId int
,@OldCompId int
)
AS
UPDATE TableName
SET Comp_Id = @NewCompId
WHERE Comp_Id = @OldCompId
AND Emp_Id = @EmpId
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply