Add text to field with existing text

M

mistux

I am trying to update a field that contains text and add some more tex
to it like I could in an MDB.

Field OrderNotes contains:

"First entry info"

I want to add to it, at the top some text so that the field no
contains:
"Second entry info"
"First entry info"


Here is what I have thus far:

(@WOID int, @Reason nvarchar(150))
AS
select[T_SetupSheetHistoryOrderNotes].OrderNotes
FROM [T_SetupSheetHistoryOrderNotes]
WHERE [T_SetupSheetHistoryOrderNotes].WOID=@WOID
UPDATETEXT [T_SetupSheetHistoryOrderNotes].OrderNotes 0 @Reaso
 
S

Sylvain Lafontaine

The UPDATETEXT is to be used with field of type TEXT, NTEXT and IMAGE and
not to be used with field of type char, varchar, nchar or nvarchar.

It is also a statement that must be used separately from a Select statement
and must be given a binary pointer; something like:

DECLARE @ptrval binary(16)

SELECT @ptrval = TEXTPTR([T_SetupSheetHistoryOrderNotes].OrderNotes )
FROM [T_SetupSheetHistoryOrderNotes]
WHERE [T_SetupSheetHistoryOrderNotes].WOID=@WOID

UPDATETEXT [T_SetupSheetHistoryOrderNotes].OrderNotes @ptrval 0 0 @Reason

Please not that I did not test the above piece of code.

With fields of type other than TEXT, NTEXT and IMAGE, you should use the
regular update statement:

Update T_SetupSheetHistoryOrderNotes
SET OrderNotes = OrderNotes + @Reason
FROM [T_SetupSheetHistoryOrderNotes]
WHERE [T_SetupSheetHistoryOrderNotes].WOID=@WOID
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top