簡體   English   中英

將 SQL 列的最大大小從 nvarchar(最大)增加到 30 萬

[英]Increase SQL column max size from nvarchar (max) up to 300 thousand

我正在嘗試在表格列中插入格式為 JSON 的大量內容。 目前它沒有拋出任何錯誤,但是在列中顯示數據時,它只打印一半輸入的詳細信息。 如何將nvarchar(max)的長度增加到nvarchar(300,000)

目前,我使用的是 SQL 服務器 15.0 版本,因此我不能使用 JSON 數據類型。

我將不勝感激這方面的任何幫助。

對於顯示問題,在結果網格中曾經有一個方便的“錯誤”,在 SSMS 中,交換 XML 列的 position 並單擊它,將顯示 XML* 列(左側或右側)的內容(這取決於結果集中 xml 的初始 position)

declare @json nvarchar(max) = concat('["a"', replicate(cast(concat(',"', newid(), '"') as nvarchar(max)), 10000), ']');
select isjson(@json) as _isjson, len(@json) as _len;

select 
'<![CDATA[content start-->'+ @json + ' <-- content end]]>' as colA, 
cast('drag me to the left of colA and click me' as xml) as b;

如果 colA 不包含任何破壞和非法 XML 字符,則實際上不需要CDATA

declare @longchar nvarchar(max) = concat('"a"', replicate(cast(concat(',"', newid(), '"') as nvarchar(max)), 10000));

select 
@longchar as colA, 
cast('drag me to the left of cola and click me' as xml) as b;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM