简体   繁体   English

SSMS中的存储过程,但不是db

[英]Stored Procedure in SSMS but not on db

The title may be confusing.... sorry 'bout that. 标题可能令人困惑....抱歉'回合那个。

I am using SQL Server 2012 SP1. 我正在使用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? 我想知道是否可以创建一个存储过程,它只存储在本地SQL Server Management Studio( SSMS )中,而不是存储在数据库中?

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. 没有办法将SP存储在数据库之外并且能够EXEC它。 Whay could help you is this: SSMS Toolpack . Whay可以帮到你: SSMS Toolpack You can create snippets containing almost any amount of code and call them by typing <snippetname>+TAB . 您可以创建包含几乎任意数量代码的代码段,并通过键入<snippetname>+TAB来调用它们。 The other solution would be to use Projects in SSMS (File>New>Project). 另一种解决方案是在SSMS中使用项目(文件>新建>项目)。 You can have all frequently used scripts listed on a toolbar and available everywhere. 您可以在工具栏上列出所有常用脚本,并随处可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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