I have a DataBase name Customer
Customer have 30 Tables name table1 、table2、table 3...
I want to have a DataBase name Customer_Offile with same Table same column like Customer ( the Customer_Offlike will used to a backup DataBase)
How to wirte a script for copy Customer?
thank you very much
Database YourDB has full backup YourBaackUpFile.bak. It can be restored using following two steps.
Step 1: Retrive the Logical file name of the database from backup.
RESTORE FILELISTONLYFROM DISK ='D:BackUpYourBaackUpFile.bak'GO
Step 2: Use the values in the LogicalName Column in following Step.
--Make Database to single user ModeALTER DATABASE YourDBSET SINGLE_USERWITH ROLLBACK IMMEDIATE--Restore DatabaseRESTORE DATABASE YourDBFROM DISK ='D:BackUpYourBaackUpFile.bak'WITH MOVE'YourMDFLogicalName'TO'D:DataYourMDFFile.mdf',MOVE'YourLDFLogicalName'TO'D:DataYourLDFFile.mdf'--If there is no error in statement before database will be in multiuser mode.--If error occurs please execute following command it will convert database in multi user.ALTER DATABASE YourDBSET MULTI_USERGO|||
sorry but .. I can' t really understand
if the DB I want to create a Backup DB named Customer
does the code should be
ALTER DATABASE Customer
SET SINGLE_USERWITH ROLLBACK IMMEDIATE -- what does Set single_user with rollback immediate? what does this code for?
if I just want a DB have same table same column as Customer I don't need to copy any Data from Customer
does the steps is
1 copy Customer as a new DB
2 delete the Data from the new DB?
how to delete ?
thank you
|||
As your problem is concerned you may follow these steps:
1. Take a backup of your respected databse.
2. Delete the data of table and remain the table structure in your table use the folllowing command:
DELETE TABLE <"table name">
3. Insert your fresh data in the table
As you use this command, your table structure remain same(no table structure modify or delete).
No comments:
Post a Comment