Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
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 25-Jul-12 2:45am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello Soft Engg....
 

Please use the below query.
 
It will help you.
 

select * into CollegeDb..newstudentinfo(DBname..tableName) from SchoolDb..StudentInformation (DBname..tableName)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

try to use SqlBulkCopy Method in ADO.Net.
Code:
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);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
Use this query:
 
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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Insert Data From One Table to Another Table[^]
 
INSERT INTO database1.table (FirstName, LastName)
SELECT FirstName, LastName
FROM database2.table 
WHERE EmailPromotion = 2
  Permalink  

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

  Print Answers RSS
0 BillWoodruff 330
1 Mathew Soji 309
2 Maciej Los 295
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 217
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,025


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100