I have created varchar(MAX) field as memo field. Unfortunately I do not find a way how to add multiline text into such field using MS SQL Server Management Studio. If I use copy/paste of multiline text only first line of multiline test is inserted into varchar(MAX) field.
You can use REPLACE('Line1@Line2@Line3', '@', CHAR(13) + CHAR(10)) , for example. Show activity on this post. All+Enter jums to next records.
The length can be specified as a value from 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.
Some Differences Between VARCHAR and TEXT The VAR in VARCHAR means that you can set the max size to anything between 1 and 65,535. TEXT fields have a fixed max size of 65,535 characters. A VARCHAR can be part of an index whereas a TEXT field requires you to specify a prefix length, which can be part of an index.
CHAR, VARCHAR, and VARCHAR(MAX) CHAR columns should be used for columns that vary little in length. String values that vary significantly in length and are no longer than 8,000 bytes should be stored in a VARCHAR column. If you have huge strings (over 8,000 bytes), then VARCHAR(MAX) should be used.
As you observe, if you paste in multi-line text only the first line is inserted, instead paste the text into an update statement and run that;
update T set fld =
'aaa
sss
ddd'
where ...
(You need to SELECT
in results to text mode to observe the lines, in the grid view they appear as double-spaces)
You can use REPLACE('Line1@Line2@Line3', '@', CHAR(13) + CHAR(10))
, for example.
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