20081122

Built In Bugs :: VarChar

Alexander Kuznetsov pointed this one out on his blog. He goes on to a longer explanation and how to test for the issue in general (see link). SS

In Transact SQL you can assign a 10-character value to a VARCHAR(5) variable, as follows:

DECLARE @c VARCHAR(5); SET @c='1234567890'; PRINT @c

12345

The value will be silently truncated without raising an error. Because of this behavior it may be very easy to make mistakes.

No comments:

Post a Comment

Be nice... it's the only internet we have.

License & copyright

Creative Commons License
StinkySQL weblog and any related pages, including the weblog's archives are licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.