In SQL 6.5 why does passing a 256 byte character string to an SP expecting a TEXT field produce a NULL when checked?

Neil Pike

November 13, 1999

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. See below for sample query.

The answer is that even though your SP takes a TEXT param, SQL has no concept of a TEXT variable or constant. It treats your constant as a char and because chars can only be 255 characters, the 256 becomes 0. You should have the same problem with 512 chars, 768 chars etc. The same problem would probably occur with SQL 7.0 and an 8001 length char.

--------

if ('914468 919215 1013036 1067140 1106909 1119345 591395
591426 591477 591491 591501 591528 591534 594829 594958
595032 595052 595065 595107 595191 595248 595343 609320
609482 611572 635771 639586 649072 653820 678868 702034
716129 797340 810128 859268 1013036' is null) print 'data
is null!'

create proc myproc
@stream text
as

if (@stream is null) print 'data is null'

go

exec myproc

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like