Skip navigation

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

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 <place a 256 character string here


TAGS: SQL
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish