An exception occurred while executing a transact-sql statement or batch

120.6k views Asked by At

I keep getting the error message:

an exception occurred while executing a transact-sql statement or batch

when trying to do anything in SQL Server Management Studio 2016.

This occurs when I try to create or edit a login, when I try to create a new database, basically when I do anything.

I tried the solution given in SQL Server 2008 R2 Express permissions -- cannot create database or modify users but I can't edit the Startup Parameters specified in step 6.

Can anyone explain what the issue is and how to solve it?

5

There are 5 answers

0
krishna On

Thanks to everyone who tried to answer the question, but I was able to solve it. It is the same procedure mentioned in SQL Server 2008 R2 Express permissions -- cannot create database or modify users. However, in step 6 instead of adding "-m" to an existing parameter, you have to create a new parameter called "-m" and follow the remaining steps. This resolved the issue.

0
user16714199 On

I fixed it a different way
I put the .bak file in "C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Backup"

0
Amir Jabari On

sometimes it happens because of the "file" that you are trying to "restore"! I mean, you have to check the "file"! The file might be a "query" by itself! and so, there will be no necessity to "restore" it! and then, your job is only "opening" it using the Microsoft SQL Server Management Studio (SSMS)! fingers crossed!

0
user1994510 On

I got this error message while trying to attach DB, if it's your case, go to to the folder where your DB is:

  • Right click => properties => security => advanced
  • Make sure the correct user has 'full control' permission
  • If not:
    • Click on 'Change permissions'
    • Set 'full control' permission to the relevant user (or all of them)
  • Try to attach again

It works for me.

0
Lahiru Gamage On

I got same issue but when i tried with query it was succeeded. try below

CREATE DATABASE databasename;