用于生成/插入代码注释部分的工具或 T-SQL 方法
我正在寻找一种在数据库中的所有视图、存储过程和 UDF(基本上是每个基于代码的模块)中半自动插入代码注释块的方法。我很乐意生成 ALTER 语句并在运行脚本之前亲自检查它们,我只是在寻找一种可靠的方法来生成它们。我不是在寻找更改 SSMS 模板的方法,这不会帮助我更改现有的 SQL 模块
显然 SP 包含 AS
或 AS BEGIN
,但视图仅包含 < code>AS 我需要确保它考虑到不同的空白。
I am looking for a way to insert code comment blocks semi-automatically in all the views, stored procedures, and UDFs in a database (basically every code-based module). I'm fine with generating the ALTER statements and reviewing them myself before running the scripts, I was just looking for a reliable way to generate them. I am not looking for a method to alter the SSMS template, which will not help me alter the existing SQL modules
Obviously SPs contain AS
or AS BEGIN
, but views only contain AS
and I need to ensure that it takes account of varying whitespace.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
SSMS 工具包(免费)具有可能有用的“SQL 片段”,但要回顾性地添加内容,并且自动可能会很痛苦。
顺便说一句,存储过程不必 BEGIN/END
From这个 BOL 链接,它显示它们是可选的(编辑:正如查尔斯提到的,我现在看到了)
SSMS tools pack (free) has "SQL Snippets" which might be useful, but to add things retrospectively and automatically could be a pain.
BTW, stored procs do not have to have to BEGIN/END
From this BOL link, it shows they are optional (edit: as Charles mentioned I see now)
我会使用 SQL Compare(来自 Red Gate)将整个架构转储到一系列 .SQL 文件中。然后,您可以轻松地将一些文本添加到文件的头部,然后重新运行 SQL Compare 将它们提交到数据库。
I would use SQL Compare (from Red Gate) to dump the whole schema to a series of .SQL files. You can then easily add some text to the head of the files before re-running SQL Compare to commit them to the database.
如果您有权访问 Visual Studio Team System 数据库版本,您应该能够完成 Joel 描述的过程(将数据库中的架构导入到 SQL Server 2XXX 项目中),然后定制 Visual Studio 提供的代码模板。 Visual Studio 帮助包含有关自定义这些模板的信息。有关详细信息,请参阅主题:“如何:查找和组织项目和项模板”。
华泰
——
奥齐梅德斯
If you have access to Visual Studio Team System Database Edition, you should be able to work through the process described by Joel (import the schema from your database into a SQL Server 2XXX project), then tailor the Code templates provided by Visual Studio. Visual Studio help contains information on customizing these templates. See the topic: "How to: Locate and Organize Project and Item Templates" for more information.
HTH
--
Ozziemedes
也许这个工具会有帮助
http://www.softtreetech.com/isql.htm
maybe this tool will be helpful
http://www.softtreetech.com/isql.htm
不幸的是,我必须手动处理这个问题 - 我用代码生成了注释并将它们粘贴到每个 SP、VIEW、TRIGGER 和 FUNCTION 中...
Unfortunately, I had to handle this manually - I code-generated the comments and pasted them into each SP, VIEW, TRIGGER and FUNCTION...