简体   繁体   中英

Stored Procedure in SSMS but not on db

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_

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM