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 ..."
但是,我似乎无法为Database对象创建模板项。我知道对于DLL / C#相关的项目,它就像“文件>导出模板......”一样简单。
How can I add new SQL templates to my Database project?
如何向数据库项目添加新的SQL模板?
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".
它只是我,或没有其他人使用项目模板?我领导了许多开发人员,并且更容易告诉他们“使用此模板”与“阅读文档并按照这种方式执行”。
2 个解决方案
#1
Found it.
Here is the folder with the files:
这是包含文件的文件夹:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\Templates\Database Project Items
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.
用您自己的替换New Stored Procedure Script.sql是直截了当的。如果要添加一个(我做过),您可以编辑NewDataItems.vsdir文件以显示自定义图标。
#2
Also see this SO question How does one customize VS 2008 Database Item Templates?
另请参阅此SO问题如何自定义VS 2008数据库项模板?
#1
Found it.
Here is the folder with the files:
这是包含文件的文件夹:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\Templates\Database Project Items
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.
用您自己的替换New Stored Procedure Script.sql是直截了当的。如果要添加一个(我做过),您可以编辑NewDataItems.vsdir文件以显示自定义图标。
#2
Also see this SO question How does one customize VS 2008 Database Item Templates?
另请参阅此SO问题如何自定义VS 2008数据库项模板?