Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Search for text in sprocs (in Azure) Expand / Collapse
Author
Message
Posted Wednesday, May 22, 2013 12:38 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 2:46 PM
Points: 34, Visits: 17
In SQL 2000 & 2005, I would use the following to search for text in my stored procedures:

DECLARE @s varchar(255)
SET @S = 'YourSearchTextHere'
DECLARE @msg varchar(255) ,@ul varchar(255)
select @s='%' + @s + '%'
select o.name , Seq=colid
,'SPLine'=substring(text,patindex(@s,text)-5, 30)
from syscomments c , sysobjects o
where o.id=c.id
AND o.name LIKE 'STP%'--Added this line to filter for my sprocs
and patindex(@s,text) > 0
order by name
SELECT @msg='* Stored procedures containing string "' + @s + '=' +
convert(varchar(8),@@rowcount) + ' *'
SELECT @ul=replicate('*',datalength(@msg))
Print ' '
PRINT @ul
PRINT @msg
Print @ul

Is there an equivalent call I can use in SQL 2012 / Azure?

When I try to use it in Azure, I get the following error:

Msg 40512, Level 16, State 1, Line 7
Deprecated feature 'String literals as column aliases' is not supported in this version of SQL Server.

Line 7 being:
'SPLine'=substring(text,patindex(@s,text)-5, 30)

If I comment that line out (as well as the last comma in the line above) I get the following error:
Msg 208, Level 16, State 1, Line 5
Invalid object name 'syscomments'.


Any ideas?

Thanks,
D



Post #1455645
Posted Wednesday, May 22, 2013 12:49 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:41 PM
Points: 13,315, Visits: 12,182
Check out SQL Search. It is 100% and written by RedGate, the sponsors of SSC.

http://www.red-gate.com/products/sql-development/sql-search/


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1455652
Posted Wednesday, May 22, 2013 2:24 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 2:46 PM
Points: 34, Visits: 17
Thanks for that link. I downloaded it and installed it.

I don't know if I am doing something wrong, but it doesn't seem to do anything when I type into the search box.



Post #1455703
Posted Wednesday, May 22, 2013 2:30 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:41 PM
Points: 13,315, Visits: 12,182
DavidMcAfee (5/22/2013)
Thanks for that link. I downloaded it and installed it.

I don't know if I am doing something wrong, but it doesn't seem to do anything when I type into the search box.


Do you have the dropdowns set? Do you the little searching bar flicker when you enter a character in the search box?

I would assume it is compatible with Azure. I can't find anything that states one way or the other on their site.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1455704
Posted Wednesday, May 22, 2013 2:48 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 2:46 PM
Points: 34, Visits: 17
OK, it must be an Azure thing.

I couldn't get it to work with out 2000 server, but did connect to my local box 2012 SS.

It does work on my local box.

hmmm, how do I search for text in sprocs in Azure...




Post #1455715
Posted Wednesday, May 22, 2013 2:53 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 2:46 PM
Points: 34, Visits: 17
I guess this answers my question :/

http://stackoverflow.com/questions/10985596/full-text-search-on-sql-azure



Post #1455716
Posted Friday, May 24, 2013 8:03 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 7:03 PM
Points: 7,099, Visits: 12,608
DavidMcAfee (5/22/2013)
I guess this answers my question :/

http://stackoverflow.com/questions/10985596/full-text-search-on-sql-azure

no, full text search is something completely different.

the problem is likely that you are still referring to the old sql 2000 system tables. e.g references to syscomments should be replaced with sys.sql_modules.

Mapping System Tables to System Views


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1456753
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse