SQL Server Text Datatype Maxlength = 65,535?

前端 未结 5 1806
忘掉有多难
忘掉有多难 2020-12-10 16:32

Software I\'m working with uses a text field to store XML. From my searches online, the text datatype is supposed to hold 2^31 - 1 characters. Currently SQL Server is trunca

相关标签:
5条回答
  • 2020-12-10 16:42

    that is a limitation of SSMS not of the text field, but you should use varchar(max) since text is deprecated

    alt text

    Here is also a quick test

    create table TestLen (bla text)
    
    insert TestLen values (replicate(convert(varchar(max),'a'), 100000))
    
    select datalength(bla)
    from TestLen
    

    Returns 100000 for me

    0 讨论(0)
  • 2020-12-10 16:45

    You should have a look at

    • XML Support in Microsoft SQL Server 2005
    • Beginning SQL Server 2005 XML Programming

    So I would rather try to use the data type appropriate for the use. Not make a datatype fit your use from a previous version.

    0 讨论(0)
  • 2020-12-10 16:55

    MSSQL 2000 should allow up to 2^31 - 1 characters (non unicode) in a text field, which is over 2 billion. Don't know what's causing this limitation but you might wanna try using varchar(max) or nvarchar(max). These store as many characters but allow also the regular string T-SQL functions (like LEN, SUBSTRING, REPLACE, RTRIM,...).

    0 讨论(0)
  • 2020-12-10 17:00

    You can use: Plase user SQL query.

    GO  
    EXEC sp_configure 'show advanced options', 1 ;   
    RECONFIGURE ;   
    GO  
    EXEC sp_configure 'max text repl size', -1 ;   
    GO  
    RECONFIGURE;   
    

    Read more in: http://blog.emdiu.com/sql-tips-configure-the-max-text-repl-size-server-configuration-option-commandtext-qua-dai--13

    0 讨论(0)
  • 2020-12-10 17:05

    If you're able to convert the column, you might as well, since the text data type will be removed in a future version of SQL Server. See here.

    The recommendation is to use varchar(MAX) or nvarchar(MAX). In your case, you could also use the XML data type, but that may tie you to certain database engines (if that's a consideration).

    0 讨论(0)
提交回复
热议问题