SQL Server - COPYING DATA FROM ANOTHER DATABASE AT SIMULTANEOUSLY

Asked By vinayak on 14-Feb-12 04:00 AM
HI FRIENDS,

I HAVE ONE DATABASE LIKE STUDENT.AND ANOTHER DATABASE IS EMPLOYEE..

I WANT COPY THE DATA STUDENT TO EMPLOYEE DATABASE.IT WILL COPY SIMULTANEOUSLY WHEN DATA IS INSERTED INTO STUDENT DATABASE IT WILL COPY EMPLOYEE DATABASE ALSO.....

PLEASE POST QUERY.......
Somesh Yadav replied to vinayak on 14-Feb-12 04:06 AM
Copy a table from one database to another database in another ms sql server using sql server management studio :

If your table was in the same ms sql server but in another database, you would copy it using t-sql like this :

SELECT * INTO NewTable FROM existingdb.dbo.existingtable;

However, if your database is in another ms sql server, you can do this :

Connect to your database using management studio. Right click on your table and select Script Table As > Create To > New Query Editor Window

Connect to the other database you want the table to be copied, create a new query and paste the sql previously generated. Run the query and you are done!
kalpana aparnathi replied to vinayak on 14-Feb-12 04:14 AM
hi,

http://dbcopytool.codeplex.com/ for article gives suggestion for your problem.

Regards,
Web Star replied to vinayak on 14-Feb-12 04:14 AM
If you can copy data from one table in to another table in another database by using Sql query than you make sure your both database exists on same server, than you will access another database table by using double dot (..) in query as follows
eg StudentDetails table in STUDENT database and StudentInfo in Employee database and you want to insert record on StudentDetails same time the record should be inserted into tudentInfo in Employee database  than you write your query as follows

Query or sp in STUDENT database

--First insert into StudentDetails  in STUDENT database
Insert into StudentDetails  Values(@name, @class,@section,.....etc)
--And just below put the query to insert record in StudentInfo in Employee database as
Insert into Employee..
StudentInfo Select * From StudentDetails