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)
 Query Help

Author  Topic 

easy_goer
Starting Member

21 Posts

Posted - 2013-09-30 : 11:33:33
Hello.

I have one table that looks something like this..

3022224 G 4980 65 3
3022224 U 4980 596 2
3022224 G 4980 67 3

And another that looks something like this..

28077 1 3022224
28078 1 3022224
28079 1 3022224

I need insert the following into another table based on the two tables above. The long number (3022224) is what I use to join the two original tables.

28077 1 G 4980 65 3
28077 1 U 4980 596 2
28077 1 G 4980 67 3
28078 1 G 4980 65 3
28078 1 U 4980 596 2
28078 1 G 4980 67 3
28079 1 G 4980 65 3
28079 1 U 4980 596 2
28079 1 G 4980 67 3

Any ideas would be much appreciated.

Thank you,
Keith

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-09-30 : 12:03:34
insert into SomeTable
select t1.Column1, t1.Column2, t1.Column3, t1.Column4, t1.Column5, t2.ColumnA, t2.ColumnB
from t1
join t2 on t1.Column1 = t2.Column1

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -