An Exception Occurred While Executing a Transact-Sql Statement or Batch

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?

8

4 Answers

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.

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

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

CREATE DATABASE databasename;

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

Your Answer

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

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest