Click here to Skip to main content
15,886,810 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

Am working on Sqlserver 2005.

I have a DATABASE with Name SchoolDb.... in this i have a table called StudentInformation with Large number of Records in this table.

I have another DATABASE with Name CollegeDb, In this Database I need to copy Student information table.


Please can you help me how to do this.

Thanks for EVER.
Posted

Hello Soft Engg....


Please use the below query.

It will help you.


SQL
select * into CollegeDb..newstudentinfo(DBname..tableName) from SchoolDb..StudentInformation (DBname..tableName)
 
Share this answer
 
try to use SqlBulkCopy Method in ADO.Net.
Code:
C#
DataTable sourceDataTable = new DataTable(); //here select data from your source database
string DestinationConnString = ""; //here place your destination databse connection string
string DestinationTableName = ""; //here your destination Table name
SqlBulkCopy bulkDataCopy = new SqlBulkCopy(DestinationConnString, SqlBulkCopyOptions.TableLock)
{
          DestinationTableName = DestinationTableName,
          BatchSize = 100000,
          BulkCopyTimeout = 360
};
bulkDataCopy.WriteToServer(sourceDataTable);
 
Share this answer
 
Hi,
Use this query:

SQL
select * into tstTbl from TestDB.dbo.Table1


This will copy all the data of Table1(Table1 is inside TestDB database) to the current table "tstTb" .


--Amit
 
Share this answer
 
Insert Data From One Table to Another Table[^]

SQL
INSERT INTO database1.table (FirstName, LastName)
SELECT FirstName, LastName
FROM database2.table 
WHERE EmailPromotion = 2
 
Share this answer
 

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