Reputation: 149
The title may be confusing.... sorry 'bout that.
I am using SQL Server 2012 SP1.
I was wondering if it's possible to create a stored procedure, which is only stored locally in SQL Server Management Studio (SSMS
), but not in the database?
My job involves a lot of debugging on distinct customers, meaning I do the same initial lookup every single time!
SELECT _id_ FROM IdTable (NOLOCK) WHERE _givenKey_ = X
This query is mandatory, and others are VERY frequent. Could I create a stored procedure locally, to just:
EXEC GetDefaults _givenKey_
Upvotes: 1
Views: 164
Reputation: 10873
Alternatively you can run the code stored in your local file system:
DECLARE @code NVARCHAR(MAX)
SELECT @code=(select cast(BulkColumn AS VARCHAR(MAX)) from openrowset(bulk 'c:\users\.......',SINGLE_BLOB) as sproc)
EXEC sp_executesql @code
Upvotes: 2
Reputation: 13191
There's no way to store SP outside of database and be able to EXEC
it.
Whay could help you is this:
SSMS Toolpack.
You can create snippets containing almost any amount of code and call them by typing <snippetname>+TAB
.
The other solution would be to use Projects in SSMS (File>New>Project). You can have all frequently used scripts listed on a toolbar and available everywhere.
Upvotes: 1