﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Joshua A. Walker  / Search All SQL Script Objects in All Databases for Text / 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 11:27:38 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>Red Gate SQL search will do this and much more as well as being totally free.http://www.red-gate.com/products/sql-development/sql-search/</description><pubDate>Tue, 21 May 2013 04:34:33 GMT</pubDate><dc:creator>FairFunk</dc:creator></item><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>Hi,There is an article posted on my Blog site where you can search for specific text in all sql server objects easily and the query is also very simple. [url=http://mstechnoblogger.blogspot.com/2009/10/search-text-in-sql-server-objects.html]Search Text in all SQL Server Object[/url]Cheers...</description><pubDate>Sat, 10 Oct 2009 04:53:26 GMT</pubDate><dc:creator>chandreshwar</dc:creator></item><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>Any suggestions on how to ignore results where the searched for text only occurs as part of a comment?</description><pubDate>Thu, 17 Sep 2009 11:10:23 GMT</pubDate><dc:creator>Congruent Influence</dc:creator></item><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>[quote][b]jwalker8680 (4/23/2009)[/b][hr]Except maybe the length issue and I wasn't aware I was running into that issue... :-P[/quote]Lucky you. I found out the hard way. :-D</description><pubDate>Thu, 23 Apr 2009 10:50:31 GMT</pubDate><dc:creator>JacekO</dc:creator></item><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>Excellent suggestions all... and all situations I never ran into ;-) ... Except maybe the length issue and I wasn't aware I was running into that issue... :-P</description><pubDate>Thu, 23 Apr 2009 10:46:09 GMT</pubDate><dc:creator>jwalker8680</dc:creator></item><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>This script crash when a database is offline:A simple where condition should is missing: SELECT [NAME] FROM Master.dbo.sysdatabases WHERE [NAME] NOT IN ('MASTER', 'TEMPDB', 'MSDB', 'MODEL')	AND Status &amp; 512 = 0</description><pubDate>Mon, 16 Mar 2009 00:58:10 GMT</pubDate><dc:creator>Yenidai</dc:creator></item><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>Don't forget to clean up and drop the #Results table if running as a script not a procedure.</description><pubDate>Fri, 13 Mar 2009 10:23:06 GMT</pubDate><dc:creator>shelleybobelly</dc:creator></item><item><title>RE: Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>There is one problem with your script: it will not find all instances of the text in SPs, Views or functions that are larger then 4000 characters and the searchabe text is close to the 4000 character position. Because SQL Server will split the code between multiple syscomments records you may end up with 'Joshua' in one syscomments record and 'A Walker' in another.In order to prevent this you could use something similarSELECT DISTINCT nameFROM syscomments SCINNER JOIN sysobjects SO ON SC.id = SO.idWHERE SC.text LIKE '%' + @FieldName + '%' UNIONSELECT DISTINCT nameFROM syscomments AS L1INNER JOIN sysobjects SO ON L1.id = SO.idINNER JOIN syscomments AS L2 ON L1.id = L2.id			AND L1.colid = L2.colid - 1WHERE RIGHT(L1.text, 50) + LEFT(L2.text, 50) LIKE '%' + @FieldName + '%' This is what I use when looking for a text in the SQL code. It only works for one database but so far I did not have a need to search all databases on a server.</description><pubDate>Thu, 19 Feb 2009 07:49:04 GMT</pubDate><dc:creator>JacekO</dc:creator></item><item><title>Search All SQL Script Objects in All Databases for Text</title><link>http://www.sqlservercentral.com/Forums/Topic651977-1476-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/Stored+Procedures/65768/"&gt;Search All SQL Script Objects in All Databases for Text&lt;/A&gt;[/B]</description><pubDate>Fri, 06 Feb 2009 13:58:20 GMT</pubDate><dc:creator>jwalker8680</dc:creator></item></channel></rss>