I want to store a string more than 8000 characters so I used VARCHAR(MAX) because its limit is 2gb.
please correct me if I am wrong Varchar(max) stores data in IN_ROW_DATA pages if the string is less than or equal to 8000. If the string is greater than 8000 then it starts storing the string in in LOB_DATA pages and pointer is stored in IN_ROW_DATA pages.
My code below is not storing the string greater than 8000 characters.
create table test(name varchar(max))
insert into test
values(replicate('a',8001)
Select len(name) from test
-- This will still give me length of 8000 and not 8001. So in this case there is no difference between varchar(max) and varchar(8000).
Can someone tell me what am I doing wrong and how to store string greater than 8000 characters.