Query for Update statement

Posted by Anurag_M84 under Sql Server on 10/15/2012 | Points: 10 | Views : 706 | Status : [Member] | Replies : 1
Hi All,

I have two tables whose structures are as follows: -

Table 1:-

Log In PayCon Name
321 ABC
456 .. DEF
654 DEF

Table 2:-

Code Data
123 321
456 654

I want to update the PayCon Column Data for LogIn "321" with the Data in "123" as the "Name" is same using the Table 2 "Code" column.

So I want to write an update query for the same.

If you can provide me solutions then I will be really helpful to you.

Anurag Manke


Posted by: Sourabh07 on: 10/15/2012 [Member] Starter | Points: 25

Please run the following code......to update the table1 column PayCon with the table2 column Data on the condition of the table2 column Code is reverse of the table1 column LogIn.....

Hopefully it will solve your problem...and if not then please let me know...

Query :

Update Table1
set PayCon=A.Data
from Table2 A
where LogIn = Reverse((cast(A.Code as varchar)))


Anurag_M84, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response