SQL Server 存储过程文件夹/分组

发布于 2024-07-27 15:52:40 字数 249 浏览 1 评论 0原文

我们目前使用的是 SQL Server 2000,但很快就会转向 2008。我正在寻找一种将相关存储过程分组到文件夹中的方法。 SQL Server 2000 似乎没有这种能力,从我的搜索来看,2008 似乎也没有。 这似乎是大多数用户想要的基本功能。 将多个项目共享的所有通用存储过程放在一个文件夹中,并将项目特定的过程放在另一个文件夹中,这不是有意义吗?

看来大多数开发人员现在执行此操作的方式是使用一些 ID_SPNAME 语法并对它们进行排序。

We are currently using SQL Server 2000 but will soon be moving to 2008. I am looking for a way to group related stored procedures into folders. SQL Server 2000 does not seem to have this ability and from my searches it looks like 2008 does not either. This seems like a basic feature that most users would want. Wouldn't it make sense to put all generic stored procedures that are shared across multiple projects in one folder and project specific procs in another?

It seems the way most devs do this now is by using some from of ID_SPNAME syntax and sorting them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

西瑶 2024-08-03 15:52:41

最常见的方法(在 SQL 2005/2008 中)是使用 模式

HR.spCalculateEmployeeCompensation
HR.spCalculateContractorBonus
Web.spAppendWebLog
Web.spUserEndSession
Reporting.spGetCurrentYearSummary
Reporting.spGetLastMonthDetail

这些模式不仅会在 SSMS 列表中直观地组织自身,而且您还可以对每个模式应用不同的权限。

The most common way to do this (in SQL 2005/2008) is by using schemas:

HR.spCalculateEmployeeCompensation
HR.spCalculateContractorBonus
Web.spAppendWebLog
Web.spUserEndSession
Reporting.spGetCurrentYearSummary
Reporting.spGetLastMonthDetail

Not only will these visually organize themselves in the SSMS list, but you can apply different permissions to each schema.

孤君无依 2024-08-03 15:52:40

在 UI 中按类型对过程和函数进行分组会很好,但 Management Studio 无法做到这一点。 使用 SQL Server 2000,我已经完成了您的建议(使用分组代码和排序作为对象前缀)。 在 2005 年和 2008 年,考虑创建模式来服务于相同的目的,并将您的对象分组到这些模式中。 请注意,对象名称以 UI 中的架构名称为前缀。

CREATE SCHEMA ShoppingCart AUTHORIZATION Joe
    CREATE PROCEDURE AddItem ...

...将在 UI 中显示为 ShoppingCart.AddItem

Sql Server 2008 中的架构

Grouping procs and functions by type in the UI would be nice, but Management Studio can't do it. Using SQL Server 2000, I've done what you suggest (prefixing objects with a grouping code and sorting). In 2005 and 2008, consider creating schemas to serve the same purpose, and grouping your objects in those. Note that the object names are prefixed with the schema name in the UI.

CREATE SCHEMA ShoppingCart AUTHORIZATION Joe
    CREATE PROCEDURE AddItem ...

... will display in the UI as ShoppingCart.AddItem.

Schemas in Sql Server 2008

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文