Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm new to SQL SMS and need help. I have been asked to check that .BAK files restored be checked using SELECT queries in SQL SMS. I have tried to create a new database but get the error "CREATE DATABASE permission denied in database 'master'. (Microsoft SQL Server, Error: 262)". It does not give much information so I can find out and Googling it didnt help either. Also if I drag and drop the .bak file into the SQL SMS window, I am told that there is no editor available??

Any help is greatly appreciated! Also, if you have any links to good tutorials, that would help too.

Thanks Mark

share|improve this question

migrated from stackoverflow.com Mar 12 '12 at 15:09

This question came from our site for professional and enthusiast programmers.

1  
You need to be able to restore the database from the backup to run queries on it: This will help you restore from a backup with SSMS: msdn.microsoft.com/en-us/library/ms177429.aspx This will help you to restore from a backup using t-sql: msdn.microsoft.com/en-us/library/ms186858.aspx –  Bridge Mar 12 '12 at 14:44
    
Thanks for all your help!! I have it working again! Woohoo! –  Mark Mar 13 '12 at 16:40
    
Hi Mark and welcome to the StackExchange network of sites. The way we show "thanks! it worked!" around these parts is to goto the answer that helped you (the most?) and click the checkmark under the upvote arrows (and preferably, to upvote the ones that were helpful as well). Glad to have you around, hope we can help some more in the future (and maybe you can help someone else?). This is true social gamification at it's finest for us nerds ;-) –  jcolebrand Mar 13 '12 at 16:52

2 Answers 2

up vote 5 down vote accepted

First, you need CREATE DATABASE permissions to create a database. The db_creator role may be best for you in this case. Second, you need to script the restore.

For example:

RESTORE DATABASE someDatabase
FROM DISK = N'D:\sql\backups\myDatabase.bak'
WITH STATS = 10 ; 
GO
share|improve this answer
    
+1. You also may need WITH MOVE options in case the folders/drives are not the same as the source system. You can figure out the filenames by first doing a RESTORE FILELISTONLY... –  Aaron Bertrand Mar 13 '12 at 3:41

The .bak file is the default file type for a SQL server DB backup file. This file is created when you use a backup database command using TSQL or SSMS. You can then use a restore command to restore the DB into your SQL server. @Bridge has provided you with two links to restore a DB using either TSQL or SSMS.

Point your restore to this .bak file and you will be able to restore the DB on your server. If you are overwriting an existing DB use the REPLACE option.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.