Add a database filegroup and file to an existing database using PowerShell

Majority of the examples I could find online to add database filegroups and/or files using PowerShell were for new databases. They made use of methods that didn’t work for what I was after. What I needed to do was add a database filegroup and file to an existing database. Examples, and until recently, documentation, I
Continue reading Add a database filegroup and file to an existing database using PowerShell

Permissions required for SQLjobvis

SQLjobvis is a tool I’ve blogged about before. For more info on what SQLjobvis is and how it can help you you can read my blog post here. A reader had commented on that post and mentioned that they didn’t have the necessary permissions to run SQLjobvis. But what are those permissions? The website doesn’t appear to
Continue reading Permissions required for SQLjobvis

The EXECUTE permission was denied on the object ‘xp_cmdshell’, database ‘mssqlsystemresource’, schema ‘sys’

A user will usually receive this error message when trying to execute xp_cmdshell and does not have sufficient permissions. To grant permissions to execute xp_cmdshell using TSQL, run the query below. To test this works I usually run the query below. To test the granted execute permissions work for the intended user, I impersonate them
Continue reading The EXECUTE permission was denied on the object ‘xp_cmdshell’, database ‘mssqlsystemresource’, schema ‘sys’

The server instance Witness rejected configure request

I noticed the following message in the SQL Server ErrorLog for one of the database servers which is in a database mirroring setup (currently the mirror). Error: 1438, Severity: 16, State: 2 The server instance Witness rejected configure request; read its error log file for more information. The reason 1427, and state 31, can be
Continue reading The server instance Witness rejected configure request

Invoke-Sqlcmd : Object reference not set to an instance of an object.

Today I was working on some PowerShell scripts where I ran into the following error message: Invoke-Sqlcmd : Object reference not set to an instance of an object. Below is the PowerShell code which was throwing the error. I discovered the culprit was the $Query parameter. The $Query parameter contents contained a TSQL query to
Continue reading Invoke-Sqlcmd : Object reference not set to an instance of an object.

Arithmetic overflow error converting expression to data type int.

While trying to execute the below TSQL query I got the following error message: SERVERNAME(User): Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type int. I gathered that I was receiving this error message because the SUM of the SQL Server database files was larger than the maximum
Continue reading Arithmetic overflow error converting expression to data type int.