Friday, February 24, 2012

How do I do this?

In my DB I have inadvertantly dropped a table. I do however have a backup. How can I get a copy of the (1) table from my backup DB to my current DB?Restore the backup and copy the table to your database, If there are no indexes and complex objects you can do SELECT INTO, SQL Server will create a simple table in your database. The other option create a new table with same name and copy the data from the restored database. Run a search for INTO in the BOL. Hope this helps.|||

Jim:

Create an empty database and restore your database to the newly created empty database. Then run the DDL to re-create the table in your old database and then copy the data from the restored database to the old database. Once you are satisfied that the old table is ok, drop the restored database.

[ Obvioulsy, I agree with Caddre. :-) ]

|||Thanks, here is the part I am missing. what is the syntax for going from one DB to another

i.e.

SELECT * INTO CurrentDB.NewTable FROM BackupDB.ExistingTable|||

Try this

SELECT * INTO CurrentDB.dbo.Newtable FROM BackupDB.dbo.ExistingTable

|||

SQL Server uses a 'four-part' naming convention. It follows this pattern:

Server.Database.schema.table

In 'normal' use, if you supply just the table name,

the 'schema' is assumed to be either the default user/owner or schema, the database is the current connected database, and the server is the current connected server.|||Thanks! That is exactly what I was looking for, issue resolved!

No comments:

Post a Comment