all groups > sql server programming > june 2007 >
You're in the

sql server programming

group:

How I compare strings that are longer than 4000 characters IN MSSQL 2000, Please help me


How I compare strings that are longer than 4000 characters IN MSSQL 2000, Please help me Orgil
6/4/2007 10:59:07 PM
sql server programming:
Hi all,
I use MSSQL 2000.
In QueryAnalyzer, I wrote belows:
=============== Code ===============

CREATE TABLE t1(
[col1] ntext NULL,
[id] int identity(1,1) PRIMARY KEY
)

INSERT INTO t1 (col1) SELECT REPLICATE('u',4000)
INSERT INTO t1 (col1) SELECT REPLICATE('u',4001)

SELECT * FROM t1 WHERE col1 LIKE col1

-------------------------------------------------- result is :
col1 id
------------------ ------
uuuuuuuu... 1

====================================

the LIKE operator seems not to work on strings that are longer than
4000 characters.
But my work uses thousands of characters in one string and
I need to do many actions on them, comparing for example.

How I compare these string values. Help me, please. It is vital for
me!!!

.... Orgil
Re: How I compare strings that are longer than 4000 characters IN MSSQL 2000, Please help me Uri Dimant
6/5/2007 12:00:00 AM
Orgil
If you want to display all characters go to Tools--Option menu in QA and
then to Result Tab and specify max characters per column





[quoted text, click to view]

Re: How I compare strings that are longer than 4000 characters IN MSSQL 2000, Please help me Uri Dimant
6/5/2007 12:00:00 AM
Orgil
SELECT id,[col1] FROM t1 WHERE datalength(col1) >=4000



[quoted text, click to view]

Re: How I compare strings that are longer than 4000 characters IN MSSQL 2000, Please help me Roy Harvey
6/5/2007 12:00:00 AM
[quoted text, click to view]

I could find nothing in the SQL Server 2000 documentation about this
but in the 2005 documentation it says the pattern is limited to 8000
bytes, which is 4000 characters when using unicode as in your example.
So the limit is not on the length of the string being searched, but on
the pattern that is being searched for.

Roy Harvey
Re: How I compare strings that are longer than 4000 characters IN MSSQL 2000, Please help me Orgil
6/5/2007 12:10:08 AM
Thank you Uri.

I need a help on only comparing two strings that are longer than 4000
characters.

INSERT INTO t1 (col1) SELECT REPLICATE('u',4000)
INSERT INTO t1 (col1) SELECT REPLICATE('u',4001)

"SELECT * FROM t1 WHERE col1 LIKE col1 " this query results only one
row while there are two rows have to be resulted actually.
I thought that the LIKE operator doesn't work on string values that
are longer than 4000 characters.
But I have string values that are longer 4000 characters and need to
compare each other these values.


[quoted text, click to view]
AddThis Social Bookmark Button