I noticed that I can write
SELECT CAST(Min(mynumber) AS VARCHAR(Max))+'mystring' AS X
as
SELECT CAST(Min(mynumber) AS VARCHAR)+'mystring' X
Will I regret leaving out the (Max) parameter?
You'll regret it in the (unlikely) situation that MAX(mynumber)
has more than 30 characters:
When n is not specified when using the
CAST
andCONVERT
functions, the default length is 30.
VARCHAR(MAX) should be used for Large Objects.It uses the normal datapages until the content actually fills 8k of data. When overflow happens, data is stored as old TEXT, IMAGE and a pointer is replacing the old content. Varchar is for Variable-length, non-Unicode character data. n can be a value from 1 through 8,000. Max indicates that the maximum storage size is 2^31-1 bytes. Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With