Solved

Select from one table and insert into another table

Posted on 2007-03-29
1
773 Views
Last Modified: 2007-03-30
I am writing a stored proc in SQL Server.
It selects value from one table and inserts those values in another table.

IF <some condition>
BEGIN
    DELETE from table1;
    SELECT column1 FROM table2;
    Insert into table3;
END

table3 has 2 columns, first one is an autogenerated number and second one needs to be fetched from table2 and inserted in table3.

Please tell me how to do this.

0
Comment
Question by:mathew189
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
Otana earned 125 total points
ID: 18821907
IF <some condition>
BEGIN
    DELETE from table1
    INSERT INTO Table3(Column2) SELECT column1 FROM table2
END
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question