Click here to Skip to main content
15,911,786 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Inside a stored procedure, I would like to update value of "COL-1" of "Table-A" from a temporary table "@TempTable" column "COL-1" 's value.

Please help me out.
With Thanks,
Rajan.
Posted
Comments
Maciej Los 18-Jul-13 9:22am    
... and where is a problem?
NPSSR 18-Jul-13 9:47am    
when i compose Update statement, the @TempTable is not recognizable. Please give me a sample.
Arpit Shrivastava 18-Jul-13 10:28am    
Can you show us a little query you designed, it would be helpful.
NPSSR 18-Jul-13 10:37am    
declare @TmpTble TABLE(EmpId nvarchar(10),EmpMonth numeric(2,0),EmpYear numeric(4,0),OpCLSL numeric(2,0))
insert into @TmpTble(EmpId,EmpMonth,EmpYear,OpCLSL)
(SELECT @atEmpID,@atMonth,@atYear,OpCLSL=(OpCLSL-(CL+SL)) FROM LeaveSummary WHERE (EmpId =@atEmpID) AND (EmpMonth = (@atMonth-1)) AND (EmpYear=@atYear))

Then,
I need to update OpCLSL column of LeaveSummary with OpCLSL column of @TmpTble.

Thanks.
NPSSR 18-Jul-13 10:56am    
yes I am trying the same "update LeaveSummary set OpCLSL = @TmpTble.OpCLSL where ..." in next line, but @TmpTble or TmpTble is not recognizable.

1 solution

You need to write your update query like this:

SQL
update LeaveSummary set OpCLSL = T.OpCLSL
FROM @TmpTble T
where ...


Please mark this as a answer if your purpose is solved.
Thanks
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900