Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does varchar(-1) mean?

What is the meaning of varchar(-1) in SQL Server 2008? Is it an alternative for varchar(max)?

like image 244
Sreejith S T Avatar asked Nov 11 '09 04:11

Sreejith S T


People also ask

What is varchar length as '- 1 in SQL?

In contrast to CHAR , VARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.

What does varchar of 1 means?

Char columns are fixed length. So even though we inserted an empty string into it we get back a single space. The next major difference is that varchar columns require an extra two bytes of storage. So a varchar(1) column actually uses three bytes not just the one byte that char(1) does.

What does varchar value mean?

As the name suggests, varchar means character data that is varying. Also known as Variable Character, it is an indeterminate length string data type. It can hold numbers, letters and special characters.

What is varchar example?

VARCHAR is a variable length string data type, so it holds only the characters you assign to it. VARCHAR takes up 1 byte per character, + 2 bytes to hold length information. For example, if you set a VARCHAR(100) data type = 'Jen', then it would take up 3 bytes (for J, E, and N) plus 2 bytes, or 5 bytes in all.


2 Answers

It's how to represent varchar(max) in .net SQLDBType (not explicitly stated, but length is -1)

I can't try it in SQL language in SQL Server right now for interest's sake: but I'm sure it's only for client code because varchar is normally strongly defined between 1 and 8000, but for max type it's not.

like image 187
gbn Avatar answered Sep 21 '22 19:09

gbn


i think it is varchar(max). I never seen it before.

like image 39
Andrew Keith Avatar answered Sep 20 '22 19:09

Andrew Keith