SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Copy rows from one table to multiple tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

alex02
Starting Member

USA
2 Posts

Posted - 05/05/2012 :  01:34:34  Show Profile  Reply with Quote
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

India
47189 Posts

Posted - 05/05/2012 :  01:40:05  Show Profile  Reply with Quote
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

USA
2 Posts

Posted - 05/07/2012 :  01:16:54  Show Profile  Reply with Quote
THANK YOU SO MUCH FOR YOUR REPLY

alex
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000