I was writing a script that kept giving me errors. After tracking it down I found that the syscomments table stores its contents in multiple rows if the information gets to long past varchar(8000) i believe.
Why does the syscomments table break the data up into multiple rows instead of 1 single larger row? performance?
syscomments.text
is nvarchar(4000) documented here:sys.syscomments (Transact-SQL), which was the best you could do back in the day.
However, you can use the newer sys.sql_modules
documented here: sys.sql_modules (Transact-SQL), which has a definition
column which is nvarchar(max)
.
for searching use:
DECLARE @Search nvarchar(500)
SET @Search=N'your text here'
SELECT DISTINCT
o.name AS Object_Name,o.type_desc --, m.definition
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
WHERE m.definition Like '%'+@Search+'%'
ORDER BY 2,1
if you are pre SQL Server 2005 you can search using the query here: SQL server table population source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With