Tuesday, 26 May 2009

[MS-sql] Error

Error message when you try import database from backup file

=======Error Message===========
Restore failed Server 'your-computer' (Micorsoft.SqlServer.Smo)

Additional information:
->An exception occurred while executing a Transact-SQL statement or batch
--> The file or filegroup 'yourfileName_log' cannot be selected for this operation.
RESTORE DATABASE is terminating abnormally.(Microsoft SQL Server, Error: 3219)

--- Solution ----- (progress as manual way)
create database that you want (ex: test)
right button click from test db
Tasks - > Restore -> Files and Filegroups...
select From device and select backup file location

---> Select "Script" from top location

Type this script on page

RESTORE DATABASE [ct3] FROM DISK = N'D:\temp\test.bak' WITH FILE = 1, MOVE N'test' TO N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\test.mdf', MOVE N'test_log' TO N'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\test_log.LDF', NOUNLOAD, REPLACE, STATS = 10

No comments: