-1

I have a strange issue: i created a simple stored procedure in Microsoft SQL Server:

@id INT,
@ntextParameter NTEXT,
...
UPDATE xxx SET [Field] = @ntextParameter WHERE ID = @id

but when i execute it with a long text, it update the table and simply cut the text without any visible error

Matteo Zambon
  • 99
  • 1
  • 11
  • 4
    Consider not using the deprecated `NTEXT` type and switching to `NVARCHAR(MAX)`, it's much easier to use in string operations. – Jeroen Mostert Aug 20 '20 at 08:54
  • 3
    [ntext, text and image](https://learn.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql?view=sql-server-ver15): "Avoid using these data types in new development work, and plan to modify applications that currently use them.". That notice has existed for **over a decade**. It's beyond time to stop using them. – Damien_The_Unbeliever Aug 20 '20 at 08:55
  • What size length `nvarchar` is `field`? – Thom A Aug 20 '20 at 08:57
  • Ok, thanks, I thought that the nvarchar was only 4000 character, but i checked and i find out that now nvarchar(max) is way longer in new version of sql server, so i will fix the database – Matteo Zambon Aug 21 '20 at 07:09

1 Answers1

0

As suggested by Jeroen Mostert and Damien_The_Unbeliever in the comments the NTEXT type field is deprecated, I found out that NVARCHAR(MAX) is longer that 4000 character (maximum storage size is 2^30-1 characters (2 GB)) and that I need

Matteo Zambon
  • 99
  • 1
  • 11