是否可以修改系统存储过程? [英] Is it possible to modify system stored procedure?

查看:40
本文介绍了是否可以修改系统存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变 sp_helpindex 系统程序,或者用我的版本替换它.

I would like to alter sp_helpindex system procedure, or rather replace it with my version.

原因是:

  • 显示 index_id
  • 显示包含的列
  • 显示过滤器定义
  • 显示填充因子
  • 显示索引大小
  • 同时显示堆信息

另外,有趣的是,我的版本性能更好(更快、读取更少、无游标).

Also, interestingly enough my version turned out to be better performing (faster, fewer reads, no cursor).

我尝试了以下方法,但没有一个奏效:

I tried the following, but none of these worked:

  • sp_rename
  • 改变程序
  • 删除程序

错误无效的对象名称'sys.sp_helpindex'.

我现在能想到的唯一选择就是添加一个新程序而不是替换现有程序.然而,有一个缺点.我希望 sp_help(它依次调用 sp_helpindex)能够无缝地获取我的更改,因此在服务器上使用 Alt+F1 的每个人都会看到更改,而无需更改每个客户端的默认 SSMS 快捷键.

The only option I can think of right now is just to add a new procedure instead of replacing existing. However, there is one disadvantage. I was hoping that sp_help (which in turn calls sp_helpindex) would pick up my change seamlessly and as a result everybody who uses Alt+F1 on the server would see the change without changing default SSMS key shortcut on every client.

推荐答案

不,您不能修改任何系统程序.您可以创建自己的并调用它;你只需要给它一个不同的 sp_ 名称,将它标记为一个系统对象,而不是把它放在 sys 模式中.

No, you can't modify any system procedure. You can create your own and call it instead; you just have to give it a different sp_ name, mark it as a system object, and not put it in the sys schema.

哦,与其从头开始创建自己的版本,Kimberly Tripp 一直在不断改进她自己的版本,针对新功能进行了更新,当然您应该获取 Kendra Little 的 sp_BlitzIndex.你可能会发现你不需要写任何东西,因为很多其他人已经重新发明了那个轮子,而且做得很好.

Oh, and instead of creating your own from scratch, Kimberly Tripp has constantly been evolving her own version, updated for new features and of course you should grab Kendra Little's sp_BlitzIndex. You might find that you don't need to write anything, because plenty of other people have already reinvented that wheel, and done it quite well.

这篇关于是否可以修改系统存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆