I have a SQL Server field of type varchar(max). I have an automated batch process that uses sqlcmd to pull data from a database and dump it into a text file. We have fields with more than 256 characters in them, and these fields get cut off unless I add something like “-y 0” to the flags in the sqlcmd call.
This gives me the full text for fields larger than 256 characters, but it also adds a great deal of whitespace–the fields are padded to make each field as big as it could possibly be according to its data type, essentially given me huge files with lots of padding and waste space.
I could fix this by adding -W to my sqlcmd flags, but this gives me an error saying that -W and -y are incompatible.
Has anyone had this problem before? Thoughts on how to solve it?
How long is your longest value? You may get away with the switches
which will cope with a width of up to 65535 characters, but will not help you beyond that.