Select from one table and insert into another table

Posted on 2007-03-29
Medium Priority
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>
    DELETE from table1;
    SELECT column1 FROM table2;
    Insert into table3;

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.

Question by:mathew189
1 Comment
LVL 11

Accepted Solution

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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

627 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