SQL Server - 查询系统对象

时间:2023-02-21
本文介绍了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 - 查询系统对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:获取结果集sql server中记录的行号 下一篇:在存储过程中为同一变量传递多个值

相关文章

最新文章