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 2005 Forums
 Transact-SQL (2005)
 Insert existing row data to new record

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-04-01 : 09:57:12
I have one table contains more than 50 columns

col1 col2............col60
501 abc............def
502 hjg............tyty
678 hjk............iukl
456 juy............lkj

now i have another table with 2 columns
col1 col2
501 172
678 345

My requirement is, i want to insert new record in first table as based on second table...For example, from second table, i will retive data row 501 172. Now i have to insert in first table for record 172 with all 501 data.

col1 col2............col60
501 abc............def
502 hjg............tyty
678 hjk............iukl
456 juy............lkj
172 abc.............def
345 hjk............iukl

G. Satish

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-01 : 10:03:25
See if you get required result though I am not sure if the table1 is normalised

select t2.col2,t1.col2,t1.col3.....t1.col60 from table1 as t1 inner join table2 as t2
on t1.col1=t2.col1


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -