How to transfer data to another database in SQLServer 2000!
4 answers
If you need to do it with code (.NET tag) then SqlBulkCopy
is your friend when you mix it with ExecuteReader
in source. Like so :
using (SqlConnection connSource = new SqlConnection(csSource)) // source db
using (SqlCommand cmd = connSource.CreateCommand())
using (SqlBulkCopy bcp = new SqlBulkCopy(csDest)) { // destination db
bcp.DestinationTableName = "SomeTable"; // destination table
cmd.CommandText = "SELECT * FROM [Foo]"; // source table
cmd.CommandType = CommandType.Text;
connSource.Open();
using(SqlDataReader reader = cmd.ExecuteReader()) {
bcp.WriteToServer(reader);
}
}
+1
a source to share
Some additional context for this transfer would be helpful. For example, this is a one-time transfer, a regular transfer, what you want to store for each transaction in DB1, or whatever.
I'm going to assume that this is a one-time or recurring event, and so I suggest Data Transformation Services (DTS) in SQL Server 2000:
0
a source to share