Click here to Skip to main content
11,583,859 members (65,751 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 1: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 OriginalGriff 390
1 Dave Kreskowiak 230
2 Sergey Alexandrovich Kryukov 210
3 virusstorm 209
4 Richard Deeming 180
0 OriginalGriff 1,523
1 Sergey Alexandrovich Kryukov 995
2 Abhinav S 696
3 Dave Kreskowiak 621
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web03 | 2.8.150603.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