Solved

Select from one table and insert into another table

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now