how to see/script definitions of system views?

≯℡__Kan透↙ 提交于 2020-01-23 03:09:09

问题


I tried to execute scripts from [1] in model database and user-defined databases but they give definitions/scripts of only user-defined (non-system) views, i.e. those that I anyway can easily get from GUI.

How can I see/script the definition/script of a system view in SQL Server 2008 R2?

[1]
Answers to question "System Views text in SQL Server 2005"
System Views text in SQL Server 2005


回答1:


select object_definition(object_id('[sys].[server_permissions]')) 
      AS [processing-instruction(x)] FOR XML PATH('') 

(The XML bit is just to prevent long definitions getting truncated when viewed in SSMS)

You can also stop the SQL Server instance. Copy the mssqlsystemresource file (on my system this is at C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\Binn\mssqlsystemresource.mdf and then re-attatch the copy under a new name).

In the reattached version it is easier to poke around and see the various definitions using normal SSMS functionality.



来源:https://stackoverflow.com/questions/3845438/how-to-see-script-definitions-of-system-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!