简体   繁体   English

如何获取所有SQL Server默认值和规则的名称

[英]How to get names of all SQL Server Defaults and Rules

I'm trying to write a query to get the names of all Rules and Defaults in the database so I can programatically drop all of them from a database without having to know their names. 我正在尝试编写查询以获取数据库中所有规则和默认值的名称,以便可以以编程方式从数据库中删除所有规则和默认值,而不必知道它们的名称。

They don't seem to be contained in sys.objects , though - so where can I find them? 但是,它们似乎似乎不包含在sys.objects -那么在哪里可以找到它们?

规则和默认

Try this 尝试这个

SELECT *
FROM   sys.objects
WHERE  type = 'r' -- to filter rules
        OR ( parent_object_id = 0 -- to restrict default constraints 
             AND type = 'd' ) -- to filter defaults 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在SQL Server上按数据库名称获取所有数据库的索引名称 - How to get index names for all databases by database name on a SQL Server 如何在SQL Server的sql表中获取没有一列的所有列名 - How to get all column names without one column in sql table in SQL Server 在 SQL Server 的单个 SQL 查询中获取所有表和视图的名称? - Get the names of all the tables and the views in a single SQL query for SQL Server? 如何在sql server中获取更新的列名 - How to get updated column names in sql server 如何在SQL Server 2012数据库中获取所有表名,行数和数据大小? - How can I get all table names, row counts and their data sizes in a SQL Server 2012 database? 如何从SQL Server动态填充树视图以获取所有表名和列名 - How to populate a treeview from SQL Server dynamically to get all table and column names 如何在SQL Server 2008中通过查询获取一张表中所有列中的几个列名 - How to get few column names among all columns in the one table with query in sql server 2008 从 SQL Server 表中获取所有非 NULL 列名 - Get all not NULL column names from a SQL Server table 如何在 SQL Server 中查找所有数据库中所有表的列名 - How to find column names for all tables in all databases in SQL Server 如何从SQL Server数据库中的“ SQL脚本”获取表名 - How to get the table names from “SQL script” in SQL Server database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM