Solved

Select from one table and insert into another table

Posted on 2007-03-29
1
768 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 35
create an aggregate function 9 31
Inserting oldest record into new table. 5 22
Return 0 on SQL count 24 28
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

775 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