Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Copy rows from one table to multiple tables

Author  Topic 

alex02
Starting Member

2 Posts

Posted - 2012-05-05 : 01:34:34
Hi

I am new to sql .please help me with this .
the following sql statement works only on one table
"insert into table1(id,name,ref,amount) select id,name,ref,amount from table where name = A"
how do i use multiple conditions such as where name = B ,C,D and copy the rows in table3,table4,table5.
Thanks in advance

alex

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-05 : 01:40:05
you've to use seperate insert statements for that

insert into table3(id,name,ref,amount) select id,name,ref,amount from table where name = 'B'

insert into table4(id,name,ref,amount) select id,name,ref,amount from table where name = 'C'
...



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

alex02
Starting Member

2 Posts

Posted - 2012-05-07 : 01:16:54
THANK YOU SO MUCH FOR YOUR REPLY

alex
Go to Top of Page
   

- Advertisement -