Groups | Blog | Home
all groups > sql server new users > september 2006 >

sql server new users : ntext invalid for local variables


Jim in Arizona
9/14/2006 2:40:48 PM
I got this error:
Msg 2739, Level 16, State 1, Line 1
The text, ntext, and image data types are invalid for local variables.

I wanted to create a stored procedure I could call from my web
application to insert data into a table. If I can't use ntext as a
variable for a stored procedure, then what do I use for the variable in
the stored proc? The datatype of the column in the sql2000 database that
the ntext variable would be inserting into is ntext.

Here's my stored proc, if it's needed:

CREATE PROCEDURE workrequest
@empname varchar(30)
,@adname varchar(30)
,@supervisor varchar(30)
,@department varchar(30)
,@location varchar(30)
,@roomarea varchar(150)
,@request ntext
,@dtrequest smalldatetime
,@ipaddress varchar(15)
AS
INSERT INTO TWorkRequest
(empname
,adname
,supervisor
,location
,roomarea
,department
,request
,dtrequest
,ipaddress)
VALUES
(@empname
,@adname
,@supervisor
,@location
,@roomarea
,@department
,@request
,@dtrequest
Jim in Arizona
9/14/2006 3:09:10 PM
Please Disregard. I was running the procedure wrong.

[quoted text, click to view]
Arnie Rowland
9/14/2006 3:10:56 PM
You could use either varchar(8000) or nvarchar(4000).

If your text value is longer than that, you could use several
varchar(8000)/nvarchar(4000) parameters and concatenate them together when
you do the INSERT.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


[quoted text, click to view]

Jim in Arizona
9/15/2006 7:56:16 AM
[quoted text, click to view]

Yea, I didn't even think of concatenation. Of course, I don't know how
to do that but I'll look into it on BOL.

For some reason I was thinking that varchar had a limit of 255
characters. Now why did I think that?? I'm assuming that 8000 characters
is the max?

Arnie Rowland
9/15/2006 9:25:44 AM
The max sizes for SQL 2000 are varchar(8000) or nvarchar(4000).

With SQL 2005, there is a new varchar(max), which has a 2 GB size limit.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


[quoted text, click to view]

Jim in Arizona
9/18/2006 3:37:47 PM
[quoted text, click to view]

2GB Size limit for varchar?? That almost defeats the purpose of the text
Arnie Rowland
9/18/2006 4:06:31 PM
I believe that text/ntext is now deprecated...

Varchar(max) allows indexing, searching, using most string manipulation
functions, etc. You should immediately switch over and stop using
text/ntext.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


[quoted text, click to view]

AddThis Social Bookmark Button