Click here to Skip to main content
11,487,979 members (77,500 online)
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 Sergey Alexandrovich Kryukov 9,193
1 OriginalGriff 8,287
2 Sascha Lefèvre 3,334
3 Maciej Los 2,946
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2015
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