Wednesday, March 21, 2012

Image Data and PATINDEX function

Hi,
I need to retrieve the offset of some text stored as image. PATINDEX does not work for image data type. What other choice do I have?
Thank you,
Amar DasAre you searching for the text or the binary pattern of the text?

Use the image datatype for storing binary data and (n)text datatype for storing text.|||Thanks Paul.

I am searching for the text. Unfortunately the table is created by my client and I can not alter it.|||Hum... Books Online seems to have some errors...

try this...
create table #Tmp(f1 text, f2 image)
insert into #Tmp values('Test number 1','Test number 1')
insert into #Tmp values('Test number 2','Test number 2')
insert into #Tmp values('Test number 3','Test number 3')
insert into #Tmp values('Test number 4','Test number 4')
select charindex(cast('r 2' as varbinary),f2),* from #Tmpsql

No comments:

Post a Comment