Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many chars are available in nvarchar(MAX)

Tags:

sql

sql-server

declare @string nvarchar(MAX) = ''

How many chars are available in @string?

like image 760
edgarmtze Avatar asked Dec 22 '22 16:12

edgarmtze


1 Answers

nvarchar(MAX) will hold up to 2GB which is about 1 billion characters since it is unicode

in your case it is 0

also take a look at this, datalength counts storage, len counts characters, for varchar these will be the same

declare @string nvarchar(MAX) = ''
select datalength(@string), LEN(@string)
GO

declare @string nvarchar(MAX) = '1'
select datalength(@string), LEN(@string)
like image 145
SQLMenace Avatar answered Jan 11 '23 01:01

SQLMenace