SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

easy_goer
Starting Member

21 Posts

Posted - 09/30/2013 :  11:33:33  Show Profile  Reply with Quote
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

USA
37471 Posts

Posted - 09/30/2013 :  12:03:34  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000