| Author |
Topic |
|
Sean_B
Posting Yak Master
111 Posts |
Posted - 2006-12-05 : 06:38:26
|
| Hi,I want to search through the stored procedures in a databaseI've tried using the following but it looks like the ROUTINE_DEFINITION truncates longer routines. Can anyone suggest an alternative.SELECT ROUTINE_NAME,ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINESWHERE ROUTINE_TYPE='PROCEDURE'and ROUTINE_DEFINITION LIKE '%execute%'Also what should I read to understand system tables and the underlying INFORMATION_SCHEMA in particularthanksSean |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 06:47:02
|
| The best source of information is Books Online.Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-05 : 10:33:02
|
| 1 Generate SQL script on procedures2 Do FindMadhivananFailing to plan is Planning to fail |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-12-05 : 12:58:59
|
| This might help:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=32319 |
 |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-12-05 : 16:00:16
|
quote: Originally posted by madhivanan 1 Generate SQL script on procedures2 Do Find
That seems a very long-winded way of doing it when you can just do a search on syscomments (or the corresponding IS views) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 16:03:31
|
Timmyquote: Originally posted by Sean_B Also what should I read to understand system tables and the underlying INFORMATION_SCHEMA in particular
Also syscomments truncates the SP code in chunks of 4000 bytes.Peter LarssonHelsingborg, Sweden |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2006-12-05 : 16:05:31
|
searching syscomments is not bulletproof because if the proc is longer than 4000 chars, the text gets split between rows, so the string you are searching for could be cut in half. INFORMATION_SCHEMA is worse because the text is truncated, as the OP said.what madhivanan suggests *is* bulletproof. SqlSpec: a fast and comprehensive data dictionary generator for SQL Server 2000/2005, Analysis Server 2005, Access 97/2000/XP/2003 http://www.elsasoft.org |
 |
|
|
mrsquish
Starting Member
1 Post |
Posted - 2011-06-09 : 19:50:05
|
| This might be of some assistance :CREATE FUNCTION [System].[ProcedureText]( @Proc sysname) RETURNS varchar(max)AS BEGINDECLARE @TSQL varchar(max)SET @TSQL = '' SELECT @TSQL = @TSQL + [text] FROM syscomments WHERE id = OBJECT_ID(@Proc)RETURN @TSQLENDGOBut you'd have to run over it with a cursor. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-06-14 : 03:52:57
|
quote: Originally posted by mrsquish This might be of some assistance :CREATE FUNCTION [System].[ProcedureText]( @Proc sysname) RETURNS varchar(max)AS BEGINDECLARE @TSQL varchar(max)SET @TSQL = '' SELECT @TSQL = @TSQL + [text] FROM syscomments WHERE id = OBJECT_ID(@Proc)RETURN @TSQLENDGOBut you'd have to run over it with a cursor.
Did you see the previous reply?You can also use object_definition functionMadhivananFailing to plan is Planning to fail |
 |
|
|
|