Copy tables between SQL databases

Since we went through and geocoded all of the Australian postcodes and suburbs we have found ourselves finding all sorts of uses for it, and have been madly going through projects and using this data.

We have the data in our master code database, and in order to make use of it in a clients project we must copy the table and its data between databases.

Open up a SQL query window in the destination database and run the following code:

SELECT * INTO NewTable FROM existingdb.dbo.existingtable;

This works so long as the SQL databases are on the same server.

Cloudmark Desktop Banner

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Bryan's Gravatar This works great to create the table in the new database and populate the data... but do you know of a way to also copy the constraints?
# Posted By Bryan | 21/03/09 00:40
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001.