Data Type Size

I Want a Char DataType which can store maximum data.
I mean which has max data storing capacity

varchar(max) or nvarchar(max)

but be careful how you use them. be sure you really need max. what are you planning on storing? there may be a better way

1 Like

Hi gbritton
Actually I was creating a dynamic query for pivoting some values but it contains more than 8000 char I think which a varchar(max) can store but I have more data then that...any solution regarding that

declare @sqlquery nvarchar(max);
set @sqlquery = N'select 42 as "the answer"'
exec sp_executesql @sqlquery;
1 Like

I was using this only but the char charatcter size is exceeding and ita getting only that much data that it can store at max.
Can you tell me exact size how much character it can store . I have read somewhere that it can store upto 8008 char

true, that's why you might want nvarchar(max). Basically char and varchar are limited to 8000 bytes since they need to fit in a page.

1 Like

varchar(max) From BOL: "max indicates that the maximum storage size is 2^31-1 bytes (2 GB)." How are you executing your dynamic SQL? Can we see that line of code?

1 Like