Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Into a Table Based on a Join Between Other Tables 1

Status
Not open for further replies.

larrydavid

Programmer
Jul 22, 2010
174
US
Hello, I am trying to create a stored procedure in SQL Server 2005 that does the following:

Based on a join between two existing tables, truncate and load (insert) records into an existing third table. It seems like it should be straightforward and I have been researching this, but cannot seem to find a good example. Maybe I'm just trying too hard, but in any case, if someone could please show me an example I would really appreciate the head start so I can be sure I have the correct syntax.

Thanks,
Larry
 
[tt]
Insert Into DetinationTable(Col1, Col2)
Select OriginTable.ColA,
OtherTable.ColX
From OriginTable
Inner Join OtherTable
On OriginaTable.KeyColumn = OtherTable.KeyColumn
Where OriginTable.SomeColumn = 'Blah'
[/tt]

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top