<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Find Stored Procedure Related to Table in Database &#8211; Search in All Stored Procedure</title>
	<atom:link href="http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Fri, 20 Nov 2009 20:17:18 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Yongji Wang</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-57606</link>
		<dc:creator>Yongji Wang</dc:creator>
		<pubDate>Fri, 13 Nov 2009 19:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-57606</guid>
		<description>--usp_dts_find_object_in_routine
--object contains table, view,stored procedure and user defined function)
create procedure usp_dts_find_object_in_routine
(
@routine_name nvarchar(200)=null
)
as

--temp variables for retrieving data from cursor
declare @temp_routine_name nvarchar(200)
declare @temp_routine_type nvarchar(200)
declare @temp_routine_definition nvarchar(4000)
declare @temp_created datetime
declare @temp_last_altered datetime

declare @temp_referred_routine_name nvarchar(200)


declare @temp_table_name nvarchar(200)
--declare @temp_table_type nvarchar(20)


--create routine container
if(object_id(&#039;temp..#temp_routines&#039;) is null)
begin
	create table #temp_routines
	(
	id int identity(1,1) primary key,
	routine_name nvarchar(200),
	referred_table nvarchar(4000),
	referred_routine nvarchar(4000),
	--table_type nvaarchar(20),
	routine_type nvarchar(20) null,
	routine_definition nvarchar(4000) null,
	created datetime null,
	last_altered datetime null
	)
end
else
begin
	truncate table #temp_routines
end 



--declare cursor for routines


declare cur_routine_list cursor for
select routine_name,routine_type,routine_definition,created,last_altered
from information_schema.routines
where routine_name=case when @routine_name is null or ltrim(rtrim(@routine_name))=&#039;&#039; then routine_name else @routine_name end
order by routine_type

open cur_routine_list
--find tables which is referred in routines
fetch next from cur_routine_list into @temp_routine_name,@temp_routine_type,@temp_routine_definition,@temp_created,@temp_last_altered
while(@@fetch_status=0)
begin
if (not exists(select * from #temp_routines where routine_name=@temp_routine_name))
begin
	insert into #temp_routines(routine_name,routine_type,routine_definition,created,last_altered)
	values(@temp_routine_name,@temp_routine_type,@temp_routine_definition,@temp_created,@temp_last_altered)
end
else
begin
	update #temp_routines
	set routine_name=@temp_routine_name,
	routine_type=@temp_routine_type,
	routine_definition=@temp_routine_definition,
	created=@temp_created,
	last_altered=@temp_last_altered
	where routine_name=@temp_routine_name
end
	--loop table list
	declare cur_table_list cursor for
	select table_name from information_schema.tables
	
	open cur_table_list
	fetch next from cur_table_list into @temp_table_name
	while(@@fetch_status=0)
	begin
		if(charindex(@temp_table_name,@temp_routine_definition)&gt;0)
		begin
			update #temp_routines
			set referred_table=isnull(referred_table+&#039;,&#039;,&#039;&#039;)+@temp_table_name
			where routine_name=@temp_routine_name
		end
		fetch next from cur_table_list into @temp_table_name
	end
	close cur_table_list
	deallocate cur_table_list

	--loop referred routine list
	declare cur_referred_routine_list cursor for
	select routine_name
	from information_schema.routines
	order by routine_type
	
	open cur_referred_routine_list
	fetch next from cur_referred_routine_list into @temp_referred_routine_name
	while(@@fetch_status=0)
	begin
		if(charindex(@temp_referred_routine_name,@temp_routine_definition)&gt;0 and @temp_referred_routine_name@temp_routine_name)
		begin
			update #temp_routines
			set referred_routine=isnull(referred_routine+&#039;,&#039;,&#039;&#039;)+@temp_referred_routine_name
			where routine_name=@temp_routine_name
		end
		fetch next from cur_referred_routine_list into @temp_referred_routine_name
	end
	close cur_referred_routine_list
	deallocate cur_referred_routine_list




fetch next from cur_routine_list into @temp_routine_name,@temp_routine_type,@temp_routine_definition,@temp_created,@temp_last_altered
end


close cur_routine_list
deallocate cur_routine_list

select *
from #temp_routines
order by last_altered,routine_name</description>
		<content:encoded><![CDATA[<p>&#8211;usp_dts_find_object_in_routine<br />
&#8211;object contains table, view,stored procedure and user defined function)<br />
create procedure usp_dts_find_object_in_routine<br />
(<br />
@routine_name nvarchar(200)=null<br />
)<br />
as</p>
<p>&#8211;temp variables for retrieving data from cursor<br />
declare @temp_routine_name nvarchar(200)<br />
declare @temp_routine_type nvarchar(200)<br />
declare @temp_routine_definition nvarchar(4000)<br />
declare @temp_created datetime<br />
declare @temp_last_altered datetime</p>
<p>declare @temp_referred_routine_name nvarchar(200)</p>
<p>declare @temp_table_name nvarchar(200)<br />
&#8211;declare @temp_table_type nvarchar(20)</p>
<p>&#8211;create routine container<br />
if(object_id(&#8216;temp..#temp_routines&#8217;) is null)<br />
begin<br />
	create table #temp_routines<br />
	(<br />
	id int identity(1,1) primary key,<br />
	routine_name nvarchar(200),<br />
	referred_table nvarchar(4000),<br />
	referred_routine nvarchar(4000),<br />
	&#8211;table_type nvaarchar(20),<br />
	routine_type nvarchar(20) null,<br />
	routine_definition nvarchar(4000) null,<br />
	created datetime null,<br />
	last_altered datetime null<br />
	)<br />
end<br />
else<br />
begin<br />
	truncate table #temp_routines<br />
end </p>
<p>&#8211;declare cursor for routines</p>
<p>declare cur_routine_list cursor for<br />
select routine_name,routine_type,routine_definition,created,last_altered<br />
from information_schema.routines<br />
where routine_name=case when @routine_name is null or ltrim(rtrim(@routine_name))=&#8221; then routine_name else @routine_name end<br />
order by routine_type</p>
<p>open cur_routine_list<br />
&#8211;find tables which is referred in routines<br />
fetch next from cur_routine_list into @temp_routine_name,@temp_routine_type,@temp_routine_definition,@temp_created,@temp_last_altered<br />
while(@@fetch_status=0)<br />
begin<br />
if (not exists(select * from #temp_routines where routine_name=@temp_routine_name))<br />
begin<br />
	insert into #temp_routines(routine_name,routine_type,routine_definition,created,last_altered)<br />
	values(@temp_routine_name,@temp_routine_type,@temp_routine_definition,@temp_created,@temp_last_altered)<br />
end<br />
else<br />
begin<br />
	update #temp_routines<br />
	set routine_name=@temp_routine_name,<br />
	routine_type=@temp_routine_type,<br />
	routine_definition=@temp_routine_definition,<br />
	created=@temp_created,<br />
	last_altered=@temp_last_altered<br />
	where routine_name=@temp_routine_name<br />
end<br />
	&#8211;loop table list<br />
	declare cur_table_list cursor for<br />
	select table_name from information_schema.tables</p>
<p>	open cur_table_list<br />
	fetch next from cur_table_list into @temp_table_name<br />
	while(@@fetch_status=0)<br />
	begin<br />
		if(charindex(@temp_table_name,@temp_routine_definition)&gt;0)<br />
		begin<br />
			update #temp_routines<br />
			set referred_table=isnull(referred_table+&#8217;,',&#8221;)+@temp_table_name<br />
			where routine_name=@temp_routine_name<br />
		end<br />
		fetch next from cur_table_list into @temp_table_name<br />
	end<br />
	close cur_table_list<br />
	deallocate cur_table_list</p>
<p>	&#8211;loop referred routine list<br />
	declare cur_referred_routine_list cursor for<br />
	select routine_name<br />
	from information_schema.routines<br />
	order by routine_type</p>
<p>	open cur_referred_routine_list<br />
	fetch next from cur_referred_routine_list into @temp_referred_routine_name<br />
	while(@@fetch_status=0)<br />
	begin<br />
		if(charindex(@temp_referred_routine_name,@temp_routine_definition)&gt;0 and @temp_referred_routine_name@temp_routine_name)<br />
		begin<br />
			update #temp_routines<br />
			set referred_routine=isnull(referred_routine+&#8217;,',&#8221;)+@temp_referred_routine_name<br />
			where routine_name=@temp_routine_name<br />
		end<br />
		fetch next from cur_referred_routine_list into @temp_referred_routine_name<br />
	end<br />
	close cur_referred_routine_list<br />
	deallocate cur_referred_routine_list</p>
<p>fetch next from cur_routine_list into @temp_routine_name,@temp_routine_type,@temp_routine_definition,@temp_created,@temp_last_altered<br />
end</p>
<p>close cur_routine_list<br />
deallocate cur_routine_list</p>
<p>select *<br />
from #temp_routines<br />
order by last_altered,routine_name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pallav Vidwans</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-55594</link>
		<dc:creator>Pallav Vidwans</dc:creator>
		<pubDate>Fri, 04 Sep 2009 11:32:43 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-55594</guid>
		<description>Hello Pinal,

Great Piece of work.

How can get the printed version of the query if we are using  &quot;sp_helptext&quot; ?

Looking forward to your sincere reply for the same.

With
Best Regards

Pallav Vidwans</description>
		<content:encoded><![CDATA[<p>Hello Pinal,</p>
<p>Great Piece of work.</p>
<p>How can get the printed version of the query if we are using  &#8220;sp_helptext&#8221; ?</p>
<p>Looking forward to your sincere reply for the same.</p>
<p>With<br />
Best Regards</p>
<p>Pallav Vidwans</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirav Pandya</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-54351</link>
		<dc:creator>Nirav Pandya</dc:creator>
		<pubDate>Sat, 01 Aug 2009 11:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-54351</guid>
		<description>is it possible to get store procedure parameter(s) dynamically in sql server 2005?</description>
		<content:encoded><![CDATA[<p>is it possible to get store procedure parameter(s) dynamically in sql server 2005?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Anderson</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-53682</link>
		<dc:creator>Dan Anderson</dc:creator>
		<pubDate>Tue, 14 Jul 2009 07:13:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-53682</guid>
		<description>To get it to work, I had to change sc.TEXT to sc.text</description>
		<content:encoded><![CDATA[<p>To get it to work, I had to change sc.TEXT to sc.text</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niyaz Ahmad</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-52682</link>
		<dc:creator>Niyaz Ahmad</dc:creator>
		<pubDate>Wed, 03 Jun 2009 09:33:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-52682</guid>
		<description>Hi Pinal,

I am from India and love to work in desired way. Its nice one to find out the table name from all sp into the system.

Cheers,
Niyaz Ahmad</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I am from India and love to work in desired way. Its nice one to find out the table name from all sp into the system.</p>
<p>Cheers,<br />
Niyaz Ahmad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rashmi</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-51398</link>
		<dc:creator>Rashmi</dc:creator>
		<pubDate>Wed, 29 Apr 2009 18:52:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-51398</guid>
		<description>This query is used by me today  and it served my purpose. Thank you :)</description>
		<content:encoded><![CDATA[<p>This query is used by me today  and it served my purpose. Thank you :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rakesh Yadav</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-50716</link>
		<dc:creator>Rakesh Yadav</dc:creator>
		<pubDate>Thu, 09 Apr 2009 12:42:39 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-50716</guid>
		<description>Nice query. Thanks a lot</description>
		<content:encoded><![CDATA[<p>Nice query. Thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramya</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-50615</link>
		<dc:creator>Ramya</dc:creator>
		<pubDate>Tue, 07 Apr 2009 11:27:39 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-50615</guid>
		<description>This query was very useful to me..
thank u very much..</description>
		<content:encoded><![CDATA[<p>This query was very useful to me..<br />
thank u very much..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-47177</link>
		<dc:creator>SQLAuthority News - Best Articles on SQLAuthority.com Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Tue, 24 Feb 2009 12:06:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-47177</guid>
		<description>[...] SQL SERVER - Find Stored Procedure Related to Table in Database - Search in All Stored procedure [...]</description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; Find Stored Procedure Related to Table in Database &#8211; Search in All Stored procedure [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sneha Shah</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-46870</link>
		<dc:creator>Sneha Shah</dc:creator>
		<pubDate>Wed, 18 Feb 2009 17:40:36 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-46870</guid>
		<description>Hi, We will have upgradation from SQL 2000 to SQL 2005. During running of upgrade advisior I got this messgae :: &quot;Outer join operators *= and =* are not supported in 90 compatibility mode&quot;. I was wonder will it be possible for us to find this kind of query. Pinal your query really works but I can not search for views. So will you help me out?

Thanks
Sneha</description>
		<content:encoded><![CDATA[<p>Hi, We will have upgradation from SQL 2000 to SQL 2005. During running of upgrade advisior I got this messgae :: &#8220;Outer join operators *= and =* are not supported in 90 compatibility mode&#8221;. I was wonder will it be possible for us to find this kind of query. Pinal your query really works but I can not search for views. So will you help me out?</p>
<p>Thanks<br />
Sneha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manesh Ponnu</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-46420</link>
		<dc:creator>Manesh Ponnu</dc:creator>
		<pubDate>Sat, 07 Feb 2009 05:13:25 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-46420</guid>
		<description>Hi Friends,
I need your help, to get the dependency table list of the stored procedure.

USE dbA
Create Procedure usp_Test
As
BEGIN
                If exists( select * from tblA)
                                SELECT * FROM tblB
END

When I execute, sp_depends usp_Test
It displays the tblB and tblA table lists

But when I call other database table  names inside my procedure, it’s not showing the results, instead of it throws the error  
‘Object does not reference any object, and no objects reference it.’

USE dbA
Create Procedure usp_Test
As
BEGIN
                If exists( select * from dbB..tblC)
                                SELECT * FROM dbB..tblD
END
Could you please help me to get these tables (tblC and tblD)

I am using SQL Server 2005 not 2008 :-(

Manesh P</description>
		<content:encoded><![CDATA[<p>Hi Friends,<br />
I need your help, to get the dependency table list of the stored procedure.</p>
<p>USE dbA<br />
Create Procedure usp_Test<br />
As<br />
BEGIN<br />
                If exists( select * from tblA)<br />
                                SELECT * FROM tblB<br />
END</p>
<p>When I execute, sp_depends usp_Test<br />
It displays the tblB and tblA table lists</p>
<p>But when I call other database table  names inside my procedure, it’s not showing the results, instead of it throws the error<br />
‘Object does not reference any object, and no objects reference it.’</p>
<p>USE dbA<br />
Create Procedure usp_Test<br />
As<br />
BEGIN<br />
                If exists( select * from dbB..tblC)<br />
                                SELECT * FROM dbB..tblD<br />
END<br />
Could you please help me to get these tables (tblC and tblD)</p>
<p>I am using SQL Server 2005 not 2008 :-(</p>
<p>Manesh P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhondiram</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-45544</link>
		<dc:creator>Dhondiram</dc:creator>
		<pubDate>Mon, 12 Jan 2009 07:13:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-45544</guid>
		<description>Would you please help me how i can find out Dependencies of views on stored procedure?
following query returns the dependencies of table but does not return the dependencies of views?

select distinct referenced_major_id from sys.sql_dependencies where
object_id = {0} //table object id</description>
		<content:encoded><![CDATA[<p>Would you please help me how i can find out Dependencies of views on stored procedure?<br />
following query returns the dependencies of table but does not return the dependencies of views?</p>
<p>select distinct referenced_major_id from sys.sql_dependencies where<br />
object_id = {0} //table object id</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: virendra</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-45460</link>
		<dc:creator>virendra</dc:creator>
		<pubDate>Thu, 08 Jan 2009 11:25:36 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-45460</guid>
		<description>Is there any system sp in sql server to get the create, insert or select script of a table instead of right clicking the table anme and selecting the particular query type(Create to, insert to or select to) as selecting from the menu takes long tme to fetch the query?</description>
		<content:encoded><![CDATA[<p>Is there any system sp in sql server to get the create, insert or select script of a table instead of right clicking the table anme and selecting the particular query type(Create to, insert to or select to) as selecting from the menu takes long tme to fetch the query?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dileep</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-45185</link>
		<dc:creator>Dileep</dc:creator>
		<pubDate>Tue, 30 Dec 2008 06:32:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-45185</guid>
		<description>Dear Pinal

The query for finding the dependencies of a table is based on the syscomments table and the like operator , so it is giving results if the dbobject is in comments section or in a part of a sentence, which is inaccurate .

Can you give me a query for this problem.

Thank You.
Dileep.</description>
		<content:encoded><![CDATA[<p>Dear Pinal</p>
<p>The query for finding the dependencies of a table is based on the syscomments table and the like operator , so it is giving results if the dbobject is in comments section or in a part of a sentence, which is inaccurate .</p>
<p>Can you give me a query for this problem.</p>
<p>Thank You.<br />
Dileep.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hiten</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-44813</link>
		<dc:creator>Hiten</dc:creator>
		<pubDate>Mon, 15 Dec 2008 12:13:38 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-44813</guid>
		<description>Can you please tell me, What will i do if i have to view th e constraints for a particular table.
Like I have add primary key constraint in a table.
Now if i want to check for that PK_Constraint what will be the query that I have to execute.
Please help.</description>
		<content:encoded><![CDATA[<p>Can you please tell me, What will i do if i have to view th e constraints for a particular table.<br />
Like I have add primary key constraint in a table.<br />
Now if i want to check for that PK_Constraint what will be the query that I have to execute.<br />
Please help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hiten</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-44812</link>
		<dc:creator>Hiten</dc:creator>
		<pubDate>Mon, 15 Dec 2008 12:10:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-44812</guid>
		<description>Hi Pinal,
This is the first time i&#039;m writing to u and lemme tell you that 
you have done an incredible job.
Thanx for the website and yeah nice query man.</description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
This is the first time i&#8217;m writing to u and lemme tell you that<br />
you have done an incredible job.<br />
Thanx for the website and yeah nice query man.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthikeyan</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-44508</link>
		<dc:creator>Karthikeyan</dc:creator>
		<pubDate>Wed, 03 Dec 2008 09:03:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-44508</guid>
		<description>hi..
that&#039;s a great query.. i am searching for this..
u r really a great man..</description>
		<content:encoded><![CDATA[<p>hi..<br />
that&#8217;s a great query.. i am searching for this..<br />
u r really a great man..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yakin</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-43856</link>
		<dc:creator>Yakin</dc:creator>
		<pubDate>Wed, 22 Oct 2008 06:32:33 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-43856</guid>
		<description>The query from Jens Johanneson is very usefull to me, thank you Jens</description>
		<content:encoded><![CDATA[<p>The query from Jens Johanneson is very usefull to me, thank you Jens</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-43436</link>
		<dc:creator>Charles</dc:creator>
		<pubDate>Wed, 01 Oct 2008 18:36:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-43436</guid>
		<description>Great article, thanks!  Just a quick extension of the example to tables referenced by all procedures and views follows

SET NOCOUNT ON 

IF OBJECT_ID(&#039;tempdb..#work&#039;) IS NOT NULL
  DROP TABLE #work

CREATE TABLE #work
     ( name sysname
      ,xtype char(2)
      ,tablename sysname )

-- List objects dependent on tables

DECLARE cur_tables CURSOR
READ_ONLY
FOR   
SELECT name
  FROM sysobjects 
 WHERE xtype = &#039;u&#039;
   AND left(name,2)  &#039;dt&#039;

DECLARE @name sysname
OPEN cur_tables

FETCH NEXT FROM cur_tables INTO @name
WHILE (@@fetch_status  -1)
BEGIN
	IF (@@fetch_status  -2)
	BEGIN
    INSERT INTO #work
    SELECT DISTINCT o.name ,o.xtype, @name as tablename
        FROM syscomments c
                INNER JOIN sysobjects o ON c.id=o.id
        WHERE c.TEXT LIKE &#039;%&#039; + @name + &#039;%&#039;
	END
	FETCH NEXT FROM cur_tables INTO @name
END

CLOSE cur_tables
DEALLOCATE cur_tables


select * 
  from #work
 order by name</description>
		<content:encoded><![CDATA[<p>Great article, thanks!  Just a quick extension of the example to tables referenced by all procedures and views follows</p>
<p>SET NOCOUNT ON </p>
<p>IF OBJECT_ID(&#8216;tempdb..#work&#8217;) IS NOT NULL<br />
  DROP TABLE #work</p>
<p>CREATE TABLE #work<br />
     ( name sysname<br />
      ,xtype char(2)<br />
      ,tablename sysname )</p>
<p>&#8211; List objects dependent on tables</p>
<p>DECLARE cur_tables CURSOR<br />
READ_ONLY<br />
FOR<br />
SELECT name<br />
  FROM sysobjects<br />
 WHERE xtype = &#8216;u&#8217;<br />
   AND left(name,2)  &#8216;dt&#8217;</p>
<p>DECLARE @name sysname<br />
OPEN cur_tables</p>
<p>FETCH NEXT FROM cur_tables INTO @name<br />
WHILE (@@fetch_status  -1)<br />
BEGIN<br />
	IF (@@fetch_status  -2)<br />
	BEGIN<br />
    INSERT INTO #work<br />
    SELECT DISTINCT o.name ,o.xtype, @name as tablename<br />
        FROM syscomments c<br />
                INNER JOIN sysobjects o ON c.id=o.id<br />
        WHERE c.TEXT LIKE &#8216;%&#8217; + @name + &#8216;%&#8217;<br />
	END<br />
	FETCH NEXT FROM cur_tables INTO @name<br />
END</p>
<p>CLOSE cur_tables<br />
DEALLOCATE cur_tables</p>
<p>select *<br />
  from #work<br />
 order by name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://blog.sqlauthority.com/2006/12/10/sql-server-find-stored-procedure-related-to-table-in-database-search-in-all-stored-procedure/#comment-41641</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Wed, 13 Aug 2008 13:41:53 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/2006/12/10/find-stored-procedure-related-to-table-in-database/#comment-41641</guid>
		<description>Hi Pinal,

This query is great!

Was wondering can it be taken one step further and be used to rename a table in the DB.

eg. change table &#039;Blah&#039; to &#039;BlahBlahBlah&#039;

Where this would update throughout the DB. Then i won&#039;t have to manually change every object.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>This query is great!</p>
<p>Was wondering can it be taken one step further and be used to rename a table in the DB.</p>
<p>eg. change table &#8216;Blah&#8217; to &#8216;BlahBlahBlah&#8217;</p>
<p>Where this would update throughout the DB. Then i won&#8217;t have to manually change every object.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
