A T-SQL string or binary type has no length, so values are cut to 1 or 30 characters

tx0/sql:string-type-without-lengthrecommendedwarningreliability/strings-and-regexdepth fastbug

What it finds

In SQL Server, varchar without a length is varchar(1) in a declaration or column and varchar(30) in CAST and CONVERT: longer values are cut off without an error. The same holds for char, nvarchar, nchar, binary and varbinary.

From the rule's source, string_type_without_length.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/sql:string-type-without-length" = "warning"

To keep one finding, suppress it with a reason: tx0 suppress ID --reason "..." writes the comment for it.

tx0 explain tx0/sql:string-type-without-length shows the same in the terminal. Found a false positive? Report it.