如何为 Visual Studio 创建新的存储过程模板?
我想为我们的开发团队创建新存储过程的模板。
但是,我似乎无法为数据库对象创建模板项。 我知道对于 DLL/C# 相关项目,就像“文件 > 导出模板...”一样简单,
如何将新的 SQL 模板添加到我的数据库项目中?
这是我的模板:
IF EXISTS (select 1 from information_schema.routines where specific_schema = '_SCHEMA_' and routine_name = '_NAME_')
BEGIN
print 'Dropping Procedure _SCHEMA_._NAME_'
DROP Procedure _SCHEMA_._NAME_
END
GO
print 'Creating Procedure _SCHEMA_._NAME_'
GO
CREATE Procedure _SCHEMA_._NAME_
(
@parameter1 int
, @parameter2 varchar(10)
)
AS
BEGIN
END
GO
GRANT EXEC ON _SCHEMA_._NAME_ TO _ROLE_
GO
谢谢!
编辑:哇,这是我第一次有一个问题一整天都没有答案!
是只有我一个人使用项目模板吗?还是没有其他人使用项目模板? 我领导了许多开发人员,告诉他们“使用这个模板”与“阅读文档并那样做”更容易。
I would like to create a template for new stored procedures for our development team.
However, I can't seem to create template items for Database objects. I know for DLL/C#-related items, it's as simple as "File > Export Template ..."
How can I add new SQL templates to my Database project?
Here's my template:
IF EXISTS (select 1 from information_schema.routines where specific_schema = '_SCHEMA_' and routine_name = '_NAME_')
BEGIN
print 'Dropping Procedure _SCHEMA_._NAME_'
DROP Procedure _SCHEMA_._NAME_
END
GO
print 'Creating Procedure _SCHEMA_._NAME_'
GO
CREATE Procedure _SCHEMA_._NAME_
(
@parameter1 int
, @parameter2 varchar(10)
)
AS
BEGIN
END
GO
GRANT EXEC ON _SCHEMA_._NAME_ TO _ROLE_
GO
Thanks!
Edit: Wow, it's the first time I've had a question a whole day without any answers!
Is it just me, or does no one else use Item Templates? I lead a number of developers, and it's easier to tell them "use this template" vs. "read the docs and do it that way".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到了。
以下是包含文件的文件夹:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\Templates\Database Project Items
可以直接将 New Stored procedure Script.sql 替换为您的自己的。 如果您想添加一个(我就是这样做的),您可以编辑 NewDataItems.vsdir 文件以显示自定义图标。
Found it.
Here is the folder with the files:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\Templates\Database Project Items
It's straight-forward to replace the New Stored Procedure Script.sql with your own. If you want to add one (which I did) you can edit the NewDataItems.vsdir file to show a custom icon.
另请参阅此问题 How does one custom VS 2008 Database Item Templates ?
Also see this SO question How does one customize VS 2008 Database Item Templates?