Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Error Message

Author  Topic 

baazil1
Starting Member

2 Posts

Posted - 2005-07-11 : 16:43:29
Here is my code.

DECLARE @find varchar(255),
@replace varchar(255),
@patfind varchar(255)

SELECT @find = 'Framer USA',
@replace = 'Economy Frame'

/* You may wish to change this for your own pattern matching
* % in MSSQL / Sybase is the standard wildcard character
* for matching anything
*/
SELECT @patfind = '%' + @find + '%'

UPDATE [Products]
SET [Description] = STUFF( [Description],
PATINDEX( @patfind, [Description] ),
DATALENGTH( @find ),
@replace )
WHERE [Description] LIKE @patfind

I am receiving the following error...
Server: Msg 8116, Level 16, State 1, Line 14
Argument data type ntext is invalid for argument 1 of stuff function.

Any ideas?

Thanks,
C

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-07-11 : 16:49:46
Ummmm, this kind of says it all:

"Argument data type ntext is invalid for argument 1 of stuff function."

You can not use string functions with text and ntext data types and your description field is probably one of them. If your the maximum value you are storing in description is less than 4000 characters (you can check this by using the MAX() and LEN functions), I would change the datatype to nvarchar(4000). I would do this by adding the nvarchar field to the table, running an update from your ntext to your nvarchar and then dropping your ntext field. Of course, back your table first.

Sean Roussy

Please backup all of your databases including master, msdb and model on a regular basis. I am tired of telling people they are screwed. The job you save may be your own.

I am available for consulting work. Just email me through the forum.
Go to Top of Page
   

- Advertisement -