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

an exception occurred while executing a transact-sql statement or batch linked server
an exception occurred while executing a transact-sql statement or batch mirroring
create database permission denied in database 'master restore headeronly is terminating abnormally
the media family on device is incorrectly formed 3241
create database permission denied in database 'master'. (microsoft sql server, error: 262)
create failed for database (microsoft sqlserver smo)
add member failed for server role dbcreator
cannot alter the server role dbcreator because it does not exist or you do not have permission

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?

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.

An exception occurred while executing a Transact-SQL statement or , An exception occurred while executing a Transact-SQL statement or batch. (​Microsoft.SqlServer.ConnectionInfo) RRS feed · SQL Server. >. Well, can you provide the script you are trying to execute?

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

CREATE DATABASE databasename;

Error: An exception occurred while executing a Transact-SQL , An exception occurred while executing a Transact-SQL statement or batch. Kim Loesch. Posted 5 years ago by Kim Loesch. R. unning our SQL bif and using the​  An exception occurred while executing a Transact-SQL statement or batch. unning our SQL bif and using the Local system acoount as the profile they are running jobs with. this was working fine until they went to SQL 2012, then it started failing with these errors: An exception occurred while executing a Transact-SQL statement or batch.

I got it fixed during restore from a backup by login as sa

[Solved] sql server connectivity problem, Error: An exception occurred while executing a Transact-SQL statement or batch when using the Restore from Backup process in the Blackbaud Management  An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) -----ADDITIONAL INFORMATION: The media family on device 'E:\BACK1.BCK' is incorrectly formed. SQL Server cannot process this media family. RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)

“An exception occurred while executing a Transact-SQL statement , You are running the query selecting 'master'(default SQL database) DB (check at the top in option to select database.) Close all the query  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.

Fix: An Exception Occurred While Executing a Transact-SQL , An exception occurred while executing a Transact-SQL statement or batch. (​Microsoft.SqlServer.ConnectionInfo) – Learn more on the  Detect, investigate, and respond to advanced threats. Confirm and manage identities. Ultimately, prevent IP theft, fraud, and cybercrime. Explore products and solutions from RSA.

SSMS v17.1 An exception occurred while executing a Transact-SQL , “An exception occurred while executing a Transact-SQL statement or batch. (​Microsoft.SqlServer.ConnectionInfo)” CREATE DATABASE  ADDITIONAL INFORMATION: An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)-----Cannot set a credential for principal 'sa'. (Microsoft SQL Server, Error: 15535)-----

Comments
  • can you post the exact code you attempt to run in the batch. You say when you "do anything", what about select 1?
  • that's the thing. i haven't even created a database yet or coded anything. i have just installed the software and this error keeps happening from the get-go.
  • you are logging in as the sa account you set up during installation?
  • Did you right-click the installation and choose "Run as Administrator"? Also, check your permissions for each SQL service you're installing, especially the db-engine--best to use an Adminstrator-type account cheers
  • Service account don't have permissions. Open configuration manager and get account name. Right click on folders (where is sql server, your default paths) and go to security and add user from conf. manager. Other options are firewall, security software, port config or there are missing system databases (like tempdb). Need more info.