Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 quick way to see which rules apply to a table?

Author  Topic 

steelkilt
Constraint Violating Yak Guru

255 Posts

Posted - 2002-09-26 : 11:32:16
Is there an existing SPROC in MS SQL Server 7.0 that will expose all rules that apply to a specific table and the fields in that table? If not, any ideas?

thx

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-09-26 : 11:41:48
Something like:

SELECT R.name AS RuleName,
C.name AS ColumnName,
T.name AS TableName
FROM sysobjects R
INNER JOIN syscolumns C ON R.id=C.domain
INNER JOIN sysobjects T ON C.id=T.id
WHERE R.Name='myRule'
--change the rule name here

Also try running sp_help 'myRule' on the rule and see what it returns. You might also want to look at all of the INFORMATION_SCHEMA views, it's possible one of them will have rule info.

OK, duhhhhhhhhhh, I just re-read your question and you want to know what rules apply to a TABLE:

SELECT R.name AS RuleName,
C.name AS ColumnName,
T.name AS TableName
FROM sysobjects R
INNER JOIN syscolumns C ON R.id=C.domain
INNER JOIN sysobjects T ON C.id=T.id
WHERE T.Name='myTable'
--change the table name here

Edited by - robvolk on 09/26/2002 11:43:39
Go to Top of Page

steelkilt
Constraint Violating Yak Guru

255 Posts

Posted - 2002-09-26 : 11:45:17
Thanks, rob. as usual, you are Aces.

Go to Top of Page
   

- Advertisement -