Accessing the body of a stored procedure
JustinPaquin
Posts: 7
Hello,
This question isn't directly related to a Red-Gate producct but as a user of your software I figured that someone here might know the answer to this question. I am trying to apply a regular expression the the bodies of all of the stored procedures in our database. My Perl script uses "INFORMATION_SCHEMA.ROUTINES.ROUTINE_DEFINITION" to get the body of the stored procedure but the value returned is an nvarchar(4000).
This of course cuts off some of our longer sp's. Does anyone know of another way to access this data?
Thanks in advance for any help
Justin
This question isn't directly related to a Red-Gate producct but as a user of your software I figured that someone here might know the answer to this question. I am trying to apply a regular expression the the bodies of all of the stored procedures in our database. My Perl script uses "INFORMATION_SCHEMA.ROUTINES.ROUTINE_DEFINITION" to get the body of the stored procedure but the value returned is an nvarchar(4000).
This of course cuts off some of our longer sp's. Does anyone know of another way to access this data?
Thanks in advance for any help
Justin
Comments
the INFORMATION_SCHEMA.ROUTINES view only shows the first 4000 characters of any SQL object (you can access the view DDL in the master database):
To view the rest of the code you must use the system tables "sysobjects" and "syscomments" directly. As an example, you can look at the following function I wrote some time ago, it returns the number of occurences of a string in a named object:
Justin