Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The text, ntext, and image data types are invalid for local variables

Tags:

How do I fix this error?

The text, ntext, and image data types are invalid for local variables. 

My proc is:

set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[GetJobInfo]     (     @jobId int,     @subject varchar(50) OUTPUT,     @Body ntext OUTPUT,     @prepared_email_id int OUTPUT     ) AS BEGIN     SET NOCOUNT ON     SELECT TOP 1 @prepared_email_id = p.[PreparedEmailID],         @subject = p.[Subject],         @Body = p.[Body]         FROM [PreparedEmails] p INNER JOIN         [Jobs] j ON p.[PreparedEmailID] =         j.[PreparedEmailID]         WHERE j.[JobID] = @jobId     RETURN END 

I don't know what the error is or how I fix it. Please help me...

like image 385
shalin gajjar Avatar asked Jan 21 '14 08:01

shalin gajjar


People also ask

What is Ntext data type?

NTEXT is a variable-length data type that can store long Unicode character strings. NTEXT can hold up to 2,147,483,647 bytes of data. The actual storage used depends on the length of the character string.

When might you use Ntext instead of Nvarchar?

ntext will always store its data in a separate database page, while nvarchar(max) will try to store the data within the database record itself. So nvarchar(max) is somewhat faster (if you have text that is smaller as 8 kB). I also noticed that the database size will grow slightly slower, this is also good.

What is the difference between text and Ntext?

Text - Variable-length non-Unicode data with a maximum length of 2^31 - 1 (2,147,483,647) characters. nText - Variable-length Unicode data with a maximum length of 2^30 - 1 (1,073,741,823) characters.

What is the ISO synonym for Ntext data type?

The ISO synonym for ntext is national text. Variable-length non-Unicode data in the code page of the server and with a maximum string length of 2^31-1 (2,147,483,647). When the server code page uses double-byte characters, the storage is still 2,147,483,647 bytes.


1 Answers

It's telling you that you are not allowed to use NTEXT as a data type for local variables.

Changing @Body ntext OUTPUT to @Body NVARCHAR(MAX) OUTPUT will get it working.

like image 102
paul Avatar answered Sep 19 '22 21:09

paul