T-SQL.co.uk
0 votes

I have loads of .rtf files, which are stored in a SQL blob, in a field/Column in my database. 


How can I search for text within this document without converting all docs back in to their respective .rtf format.



by (1.1k points)

1 Answer

0 votes

This should do the trick:


SELECT * FROM
( SELECT ID , [VERSION] , NAME , deleted,
ROW_NUMBER() OVER ( PARTITION BY ID ORDER BY [VERSION] DESC ) AS rown , [DOCUMENT]
FROM dbo.SOURCEDOCUMENTS ) x WHERE rown = 1
AND convert(varchar(max),convert(varbinary(max),[DOCUMENT])) LIKE '%something%'


by (1.1k points)
Welcome to T-SQL.co.uk, where you can ask questions and receive answers from other members of the community.
12 questions
15 answers
0 comments
1,643 users