Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to SELECT and UPDATE in one query using Different Tables in sql server?
Posted
Comments
Sunasara Imdadhusen 16-Nov-10 0:16am    
Not clear!
velmahesh 16-Nov-10 1:11am    
first select the id based on both tables,then want update the table.

Hi,

This may useful for you.

SELECT table1.column1, table2.column2 FROM table1, table2 WHERE table1.column1 = table2.column1;

You can use the stored procedure for update the different table columns.

Thanks
Saranya1388
 
Share this answer
 
It is Solved.:rose:

SQL
IF  EXISTS  (SELECT 1   FROM    InsCarrier  WHERE   (InsCarrierId = @InsCarrierId))
        UPDATE  InsCarrier
        SET     UserId = @UserId,InsCarrierName=@InsCarrierName
        WHERE   (InsCarrierId = @InsCarrierId)
    ELSE
        INSERT  INTO    InsCarrier  (UserId,InsCarrierName)
                        VALUES      (@B2bUserId,@InsCarrierName)
 
Share this answer
 
v2
during i will update the record, then the Selected record id is same.
 
Share this answer
 
Comments
JF2015 16-Nov-10 1:13am    
Update your question instead of posting fake answers!

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