-------------------------------------------------------------------------------------------------- -- -- File Name: sqlscript.sql -- -- Description: Blank SQL script -- -- Comments: This blank script is intended for advanced users. -- To create a script from an existing database with step-by-step -- instructions, use the Database Import Wizard. -- --------------------------------------------------------------------------------------------------- IFEXISTS (SELECT*FROM master.dbo.sysdatabases WHERE name ='DBTest') BEGIN EXEC sp_detach_db 'DBTest', 'true' END CREATEDATABASE[DBTest]ONPRIMARY (FILENAME = 'C:/DBTest_Data.MDF') LOGON (FILENAME = 'C:/DBTest_Log.LDF') FOR ATTACH GO
Text Replacement: c:/ --> [INSTALLDIR]
-------------------------------------------------------------------------------------------------- -- -- File Name: sqlscript.sql -- -- Description: Blank SQL script -- -- Comments: This blank script is intended for advanced users. -- To create a script from an existing database with step-by-step -- instructions, use the Database Import Wizard. -- --------------------------------------------------------------------------------------------------- IFEXISTS (SELECT*FROM master.dbo.sysdatabases WHERE name ='DBTest') BEGIN --备份数据库 DECLARE@PathNVARCHAR(50) SET@Path='C:/DBTest_'+CONVERT(NVARCHAR(50), GETDATE(), 120) BACKUPDATABASE[DBTest]TODISK=@Path EXEC sp_detach_db 'DBTest', 'true' END