Ram Shankar Yadav's Blog!

My life's my passion!
posts - 172, comments - 566, trackbacks - 91

My Links

News


Microsoft Certified Professional Developer (MCPD) - .NET 2.0 Enterprise Application Development



Cheap Website Hosting - Free Domain

Twitter












Archives

Post Categories

Image Galleries

Blogs that I like most !

Sites that I like most !

FindTextInDatabase - stored procedure to find text in SQL Server

 =========================================================================
 Author: Ram Shankar Yadav
 Create date: May 22, 2007
 Description: Used for  administrative purpose to find a particular text 
in the database for example columnName, Table name etc etc =========================================================================
CREATE PROCEDURE [dbo].[FindTextInDatabase] -- Add the parameters for the stored procedure here @text varchar(200) AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; declare @newString varchar(205) Set @newString = '%' + @text + '%' -- Insert statements for procedure here select name from sysobjects where id in (select id from syscomments where text like @newString) order by name END

 

Happy Coding Nerd

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted on Tuesday, May 22, 2007 8:52 PM |

Feedback

Gravatar

# re: FindTextInDatabase - stored procedure to find text in SQL Server

oohhh....it's so good!
9/28/2007 7:59 PM | yamcho
Gravatar

# re: FindTextInDatabase - stored procedure to find text in SQL Server

It's wow!! i did it in other way, but this is really good 1
10/8/2007 5:57 PM | Govind
Gravatar

# re: FindTextInDatabase - stored procedure to find text in SQL Server

Hey, using subquery is costly, insterd use join
------------------------------------------------
CREATE PROCEDURE [dbo].[FindTextInDatabase]
-- Add the parameters for the stored procedure here
@text varchar(200)

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @newString varchar(205)
Set @newString = '%' + @text + '%'
-- Insert statements for procedure here
select so.name from sysobjects so join syscomments sc on so.id = sc.id
where sc.text like @newString
order by name
END
10/8/2007 6:21 PM | Govind
Gravatar

# re: FindTextInDatabase - stored procedure to find text in SQL Server

use distinct also in select other wise will get duplicate record.

Regards../
Mukesh
3/27/2008 12:37 PM | Mukesh Bhootra
Gravatar

# re: FindTextInDatabase - stored procedure to find text in SQL Server

Dude I love you!
5/26/2008 3:00 PM | Cheeseroll
Gravatar

# How could I find stored procedure input parameters in SQL Server 2000

Hello.

I've got one problem from my client suport team. Whey want to compare input\output parameters of stored procedures from two servers. I know how to make it in SQL server 2005(sys.paramters table), but could perform it on SQL 2000.
Could you please help me?
12/23/2008 12:19 PM | Alex
Gravatar

# re: FindTextInDatabase - stored procedure to find text in SQL Server

This proc is dangerous. If the text spans a multiple of 8000 it won't be picked up as the text column of syscomments is split over multiple rows.

Only use this if you understand the results aren't going to be correct 100% of the time.
8/5/2010 2:22 PM | Jez
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: