Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Default Binding from another table

Author  Topic 

rico1931
Starting Member

37 Posts

Posted - 2009-06-24 : 14:10:38
Howdy folks..

I want 2 columns in one of my tables to have a default value from another table on insert. So I have column A1, B1, and C1 in Table 1. and in table 2 I have Column A2, B2 and C2.. I want on insert of something new in table 1 column A1 when matched to column A2 in table 2 to insert the records that are in Column B2 and C2 from table 2 into table 1 column B1 and C1.


hmm hope that makes sense...

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-06-24 : 14:30:50
After the insert is done ...you can use the update the TableA as below.

Update A
set A.B1 = B.B2, A.C1 = B.C2
from Table1 A inner join Table2 B on A.A1 = B.B2
Go to Top of Page
   

- Advertisement -