In SQL, if you declare a string in any of the four formats, CHAR, NCHAR, VARCHAR, or NVARCHAR, without specifying its length, the string is given the length of one character. If you coerce a string using CAST or CONVERT and make the same mistake, it gets a length of thirty characters. Why one and thirty? Historical reasons only, but other RDBMSs react in similar ways.
In either case, you can get yourself into trouble with "silent" string truncation, so SQL Prompt has some built-in code analysis rules to warn you if you forget to specify string length both during variable-length string declaration (BP007) and coercion (BP008).
from DZone.com Feed http://bit.ly/2sTag1Z
No comments:
Post a Comment