Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Limit to data allowed in a LIKE statement?

Author  Topic 

KHeon
Posting Yak Master

135 Posts

Posted - 2003-11-26 : 11:33:32
Hello!

I have an interesting issue. One of my clients has reported that when they enter in data which does a LIKE search a series of records are returned. If they add one more character to the search (which is still valid, based on the initial result set) nothing returns.

My thought is that there is a limit to the number of characters SQL Server allows when doing LIKE comparisons. Is this so? I can't find anything definitive in BOL and the string that works is 28 characters in length (w/spaces) and 26 (w/out spaces).

Just trying to understand why this might be happening. Thanks!

Kyle Heon
PixelMEDIA, Inc.
Senior Application Programmer, MCP
kheon@pixelmedia.com

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2003-11-26 : 11:38:30
Can you show us a sample of the sql query and the sample input + sample result set?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-11-26 : 11:38:41
I'd say the either it's not like the entry, or something else is going on


USE Northwind
GO

CREATE TABLE myTable99 (Col1 varchar(8000))
GO

INSERT INTO myTable99(Col1) SELECT REPLICATE('x',8000)

SELECT * FROM myTable99 WHERE Col1 LIKE REPLICATE('x',8000)+ '%'

DROP TABLE myTable99
GO




Brett

8-)

EDIT: Sniped...by 11 seconds
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2003-11-26 : 14:15:50
More likely the string is getting truncated somewhere to lose the %.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -