I have an outdated database, but I would like to keep the data from this database in a separate version of the current working database. I created a copy of my current database, but it has all new data in it. Is there a way to remove all of this data and then import the data from the outdated database?
Connect to the appropriate instance of the SQL Server Database Engine, and then in Object Explorer, select the server name to expand the server tree. Right-click Databases, and then select Restore Database. The Restore Database dialog box opens. Select the database to restore from the drop-down list.
Using SQL Server Management StudioIn Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance. Expand Databases, right-click the database to delete, and then click Delete. Confirm the correct database is selected, and then click OK.
Backup and restore SQL database from one server to anotherLaunch SQL Server Management Studio and connect to the instance you want to backup. Then right-click the specific database, choose Tasks > Back Up. 2. Make sure the backup type is full backup, and then select a destination.
Try this to remove data:
-- disable all constraints
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
-- delete data in all tables
EXEC sp_MSForEachTable "DELETE FROM ?"
-- enable all constraints
exec sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
To import data:
Once completed, return to the Query Window with the scripted objects. Change the USE directive (the first line) to point to the destination database (e.g., USE [Northwind]), and execute the script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With