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

sql server new users : nText in triggers


Steph
2/17/2006 11:12:02 AM
I want to do something like this

Select @MyText = LongDescription
From MyTable
Where id = inserted.[ID]

I get an error message telling me that nText is invalid for a local variable
how can I do this?

Mike Hodgson
2/20/2006 12:00:00 AM
You need to post more info about what you're trying to do in your trigger.

Why do you need to use a local variable? If nothing else, that will
cause problems when the trigger is fired on a set of more than 1 row
(because SQL Server will object to putting LongDescription from multiple
rows into a single variable - it's just not possible to encompass a set
of data within a single scalar variable). Set based operations are
usually far more efficient than this row-by-row way of processing data.

Can you post your whole trigger (or at least pseudo-code of what you're
trying to do in your trigger)? What about the tables affected/touched
by the trigger? Schema? Data? Expected results?

--
*mike hodgson*
http://sqlnerd.blogspot.com



[quoted text, click to view]
AddThis Social Bookmark Button