SQL Server - 查询系统对象

SQL Server - Querying sysobjects(SQL Server - 查询系统对象)
本文介绍了SQL Server - 查询系统对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我注意到,当我查询 dbo.sysobjects 时,为了确定我的数据库中的所有对象,它还会选取名称以syncobj_"开头的所有系统视图.它们的 xtype 为V",除了检查视图名称外,我似乎无法知道这些是系统视图,而不是我自己的视图.还有其他方法吗?我想从我正在创建的查询中排除这些.

I notice that when I query dbo.sysobjects, to determine all the objects in my database, it also picks up all system views whose name starts with 'syncobj_'. These have an xtype of 'V' and there doesn't appear to be any way I can know these are system views, and not my own, except by examining the name of the view. Is there some other way? I would like to exclude these from a query I'm in the process of creating.

推荐答案

参见 OBJECTPROPERTY:

IsMSShipped

IsMSShipped

任何模式范围的对象

在安装 SQL Server 期间创建的对象.1 = 真 0 = 假

Object created during installation of SQL Server. 1 = True 0 = False

像这样使用它:

SELECT * from sysobjects where OBJECTPROPERTY(ID,N'IsMSShipped') = 0

虽然它的文档有点偏离 - 它还可以帮助您排除by"添加的其他对象.SQL Server 稍后也 - 例如任何与复制相关的对象也被视为 IsMSShipped.

It's documentation is a bit off though - it also assists you with excluding other objects added "by" SQL Server at a later date also - e.g. any replication related objects are also considered to be IsMSShipped.

这篇关于SQL Server - 查询系统对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Error casting varchar containing a number expressed in scientific notation to decimal(将包含以科学记数法表示的数字的 varchar 转换为十进制时出错)
Calculate cumulative product value(计算累积产品价值)
SQL Server loop for changing multiple values of different users(用于更改不同用户的多个值的 SQL Server 循环)
SQL Server 2008: Can a multi-statement UDF return a UDT?(SQL Server 2008:多语句 UDF 能否返回 UDT?)
Merge columns in sql(合并sql中的列)
SQL Column is invalid in ORDER BY, not contained in aggregate or GROUP BY(SQL 列在 ORDER BY 中无效,未包含在聚合或 GROUP BY 中)