patternsqlMinor
Execute sp_WhoIsActive as a query
Viewed 0 times
queryexecutesp_whoisactive
Problem
I am at a client where they don't allow Adam Machanic's
sp_WhoIsActive stored procedure to be installed anywhere on the SQL server. Does anyone have any suggestions for running it as a query instead?Solution
In general you can run any SP as a query by getting rid of the "CREATE PROCEDURE" part and defining all of the parameters as variables.
For example
Would become
You might also ask them if it is ok if you create a "DBA" database for code like this and put the SP there. That way the SP is on the instance and will run correctly, but is still segregated from the rest of their databases.
For example
CREATE PROCEDURE test (@var1 int, @var2 int) AS
PRINT @var1
PRINT @var2Would become
DECLARE @var1 int
DECLARE @var2 int
PRINT @var1
PRINT @var2You might also ask them if it is ok if you create a "DBA" database for code like this and put the SP there. That way the SP is on the instance and will run correctly, but is still segregated from the rest of their databases.
Code Snippets
CREATE PROCEDURE test (@var1 int, @var2 int) AS
PRINT @var1
PRINT @var2DECLARE @var1 int
DECLARE @var2 int
PRINT @var1
PRINT @var2Context
StackExchange Database Administrators Q#37027, answer score: 3
Revisions (0)
No revisions yet.