February 10, 2004 at 6:15 pm
Hi, i am running a create Database Script, but need to move the Database, depending on where the user has there SQL\Data path, this script ties into an install Wizard that i am writing, when running the Script in Query Analyzer i receive the following Message, Is this a problem?? i cant seem to find anything in the Help about this message;
1stly i create the DB as normal, then i restore it from a Backup Device in Sql called VirtualManager6, then i move the Database to the Specified Folder, then i have to Detach and Attach the Database. If i dont Detach and Attach at the end, when going into SQL Enterprise Manager the database will stay on the Status of Loading and will not work....
The restore works fine and i can use the Database in Enterprise Manager ok, i am just curious as to why i am getting this message if everything seems in working order ?!
The message i am getting is.....
Restoring Database VMConfig...
Processed 1368 pages for database 'VMConfig', file 'VMConfig_Data' on file 1.
Processed 1 pages for database 'VMConfig', file 'VMConfig_Log' on file 1.
RESTORE DATABASE successfully processed 1369 pages in 2.497 seconds (4.488 MB/sec).
Server: Msg 947, Level 16, State 1, Line 1
Error while closing database 'VMConfig' cleanly.
The script is as follows....
CREATE DATABASE VMConfig
ON
( NAME = VMConfig,
FILENAME = 'D:\MSSQL\mssql\VMConfigData.mdf',
SIZE = 15,
FILEGROWTH = 5MB )
LOG ON
( NAME = 'VMConfigLog',
FILENAME = 'D:\MSSQL\mssql\VMConfigLog.ldf',
SIZE = 5,
FILEGROWTH = 5MB )
GO
PRINT ' VMConfig database created'
GO
PRINT 'Restoring Database VMConfig...'
GO
RESTORE DATABASE VMConfig
FROM VirtualManager6
WITH NORECOVERY,
FILE = 1,
Move 'VMConfig_Data' TO 'd:\Mssql\Mssql\Data\VMConfig_Data.mdf',
Move 'VMConfig_Log' TO 'd:\Mssql\Mssql\Data\VMConfig_Log.ldf'
GO
EXEC sp_detach_db 'VMConfig', 'true'
GO
EXEC sp_attach_db @dbname = N'VMConfig',
@filename1 = N'd:\mssql\mssql\data\VMConfig_Data.mdf',
@filename2 = N'd:\mssql\mssql\data\VMConfig_Log.ldf'
GO
February 11, 2004 at 12:48 am
No real answer to your question, but...
why do you create the db first and then do the shuffling around?
There's no need for that at all. Just find out where to place the restored db,
and restore it to that location directly. Done.
You don't have to create the db first in order to restore it, so it's unnecessary, along with the detach / attach steps, they are also redundant.
=;o)
/Kenneth
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply