Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I would like to know how to create a copy of data from one table going to another table.

I tried this code but does not work

SQL
SELECT * INTO s_tbl1 IN 'server=localhost;User Id=root;password=password;Persist Security Info=True;database=test' FROM s_tbl2



Thanks
Posted
Comments
[no name] 18-May-13 17:21pm    
Did you actually mean to paste a connection string in your SQL statement or do you think that a connection string in your SQL statement would work? What, exactly, does "does not work" mean?

1 solution

Basically you have to write a trigger on your main table from which you want to copy the data. This trigger should insert a new record in your second table by copying the inserted row data, whenever there is insert of new record happens in the main table.

Follow this link on how to create triggers: Triggers -- Sql Server[^]
 
Share this answer
 
Comments
JMAM 18-May-13 23:22pm    
Thanks, This will be helpful. I didn't know their is a function like that But i am using MySQL would it also work?

Also Table 1 is from a MYSQL LOCALHOST while Table 2 is from a MYSQL Cloud

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900