0

I have a database with .sql extension which is exported from server using putty.

How to import this into SQL Server 2012 in Management Studio?

It is not accepting .sql as database, throwing error.

If I try to restore using

RESTORE HEADERONLY FROM DISK = N'D:\LogFile\accesslog.sql';

I am getting the following error:

Msg 262, Level 14, State 1, Line 1
CREATE DATABASE permission denied in database 'master'.

Msg 3013, Level 16, State 1, Line 1
RESTORE HEADERONLY is terminating abnormally.

Please help me with this.

  • 1
    the credentials you are using don't have CREATE DATABASE permission to create new datebase, try login with sa or ask administrator to add your login to sysadmin role. – vijayp Dec 4 '14 at 6:13
  • Do i need to have this 'Create Database' permission to import database which already contains tables in it . – Kavi Dec 4 '14 at 8:36
  • "exported from server using PuTTY" makes me think you didn't export from a Windows machine. The .sql extension makes me think it was a MySQL database. I would try to open the .sql file with a text editor: if it contains a lot of INSERT...VALUES it is a MySQL export. – spaghettidba Dec 4 '14 at 8:58
  • yes..i exported the file from putty. This is the DB ,not a table. In SQL 2012 it is throwing error,since it is expecting .bacpac extension to import a DB. it contains lot of inserts,create statements – Kavi Dec 4 '14 at 9:15
  • Yes, you need CREATE DATABASE permissions to create a database, even if it was an export from another server. You also need to let us know what type of database you exported from. Was it SQL Server? MySQL? Oracle? – Mark Sinkinson Dec 4 '14 at 9:27
1

You can't directly restore a MySQL backup to MSSQL. What you can do is use tools such as Microsoft SQL server migration assistant.

But those still won't help you if you don't have the proper permissions on the destination server. You'll most likely be creating a database, editing schemas and creating logins and users. Which means you need the sysadmin role.

Possible duplicate of this question or this question.

1

From BOL:

If the database being restored does not exist, the user must have CREATE DATABASE permissions to be able to execute RESTORE. If the database exists, RESTORE permissions default to members of the sysadmin and dbcreator fixed server roles and the owner (dbo) of the database (for the FROM DATABASE_SNAPSHOT option, the database always exists).

You're creating a database on your server, regardless of the fact that it already existed on another server, therefore you need CREATE DATABASE permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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