﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / how to find dependent objects on Default or Rule in sql 2008 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 22:55:57 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: how to find dependent objects on Default or Rule in sql 2008</title><link>http://www.sqlservercentral.com/Forums/Topic1407059-391-1.aspx</link><description>and some ready made code to test it: creates a rule and a column that uses it:[code]CREATE RULE [dbo].[NumericCharsOnly] AS--@value  NOT LIKE '%[0-9,-+]%' ESCAPE '!' --bad way...minus and spec chars need to be first!@value  NOT LIKE  '%[^-+,0-9]%' ESCAPE '!'GO--create a "type" , and bind the rule to teh typeCREATE TYPE [dbo].[numchar] FROM [varchar](20) NULLGOEXEC sys.sp_bindrule @rulename=N'[dbo].[NumericCharsOnly]', @objname=N'[dbo].[numchar]' , @futureonly='futureonly'GO--a simple test table.drop table examplecreate table example(exampleid int identity,test numchar)--insert some test data.insert into example(test) values ('0000')GOinsert into example(test) values ('00a00') --fails! all is goodGOinsert into example(test) values ('0000&amp;444') --fails as expectedGOinsert into example(test) values ('-0000') --failed when i did not want it tooGOinsert into example(test) values ('+0000') --failed when i did not want it tooGOdrop  table exampledrop type  [numchar]drop rule [NumericCharsOnly][/code]</description><pubDate>Thu, 17 Jan 2013 08:39:48 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: how to find dependent objects on Default or Rule in sql 2008</title><link>http://www.sqlservercentral.com/Forums/Topic1407059-391-1.aspx</link><description>this gets me a lot of information about any table/columns that have a rule:[code]  SELECT OBJECT_NAME(OBJS.object_id) As TableName,*  FROM sys.columns COLS     INNER JOIN sys.objects OBJS      ON OBJS.[object_id] = COLS.[object_id]    INNER JOIN sys.sql_modules MODS      ON COLS.[rule_object_id] = MODS.[object_id]  WHERE COLS.[rule_object_id] &amp;lt;&amp;gt; 0[/code]</description><pubDate>Thu, 17 Jan 2013 08:38:04 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: how to find dependent objects on Default or Rule in sql 2008</title><link>http://www.sqlservercentral.com/Forums/Topic1407059-391-1.aspx</link><description>Dependency information is not created or maintained for rules, defaults, temporary tables, temporary stored procedures, or system objects.[url]http://msdn.microsoft.com/en-us/library/ms345449%28v=sql.105%29.aspx[/url]</description><pubDate>Thu, 17 Jan 2013 07:54:17 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: how to find dependent objects on Default or Rule in sql 2008</title><link>http://www.sqlservercentral.com/Forums/Topic1407059-391-1.aspx</link><description>Thanks for your answer but My question has a problem.It should have been that I am not able to see dependent object of rule through sp_depends,I tried all ways given in books online??</description><pubDate>Thu, 17 Jan 2013 07:43:24 GMT</pubDate><dc:creator>sej2008</dc:creator></item><item><title>RE: how to find dependent objects on Default or Rule in sql 2008</title><link>http://www.sqlservercentral.com/Forums/Topic1407059-391-1.aspx</link><description>Query sys.default_constraints, link it back to sys.columns and you get the default name, table name and column name.For rules, they are a depereciated feature, you should consider changing them all to check constraints.[code="sql"]SELECT	OBJECT_NAME(sc.rule_object_id) AS RuleName	,OBJECT_NAME(sc.object_id) AS TableName    ,sc.name AS ColumnNameFROM 	sys.objects soJOIN 	sys.columns sc    ON     so.object_id = sc.rule_object_idWHERE 	so.type_desc = 'rule'[/code]</description><pubDate>Tue, 15 Jan 2013 01:40:29 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>how to find dependent objects on Default or Rule in sql 2008</title><link>http://www.sqlservercentral.com/Forums/Topic1407059-391-1.aspx</link><description>I am able to see the list of columns or table which is bound to my rule or default using sp_depends.what are other ways to find it?</description><pubDate>Tue, 15 Jan 2013 00:53:28 GMT</pubDate><dc:creator>sej2008</dc:creator></item></channel></rss>