Although the article does only use an
varchar does work as well. Any of the examples in the documentation work exactly the same if you use a
varchar variable/column and remove the
N prefix from the string literal declarations.
SQLServer does return an
nvarchar(MAX) as well when using
FOR JSON AUTO (see below example), however, again that doesn't mean you can't store it in a
varchar. Just like with any string storage in SQL Server, there's little point in using an
nvarchar if your values are never going to have a character out of the collation's ASCII range.
CREATE TABLE dbo.test (value1 varchar(10),
INSERT INTO dbo.test (value1,
FROM sys.dm_exec_describe_first_result_set('SELECT * FROM dbo.test FOR JSON AUTO;',NULL,0);
DROP TABLE dbo.test
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.