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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Add text to existing text in a field

Author  Topic 

mistux
Yak Posting Veteran

90 Posts

Posted - 2005-06-25 : 13:10:30
I am tryign to update a field that allready contains data with some new data.

Example for field OrderNotes:

Existing:
"Order received."

What I want to add to it:
"Order halted 6-25-05"

What should now be in the field OrderNotes (without quotes):
"Order halted 6-25-05"
"Order received."

Here is what I thought I could use:

(
@WOID int,
@Reason nvarchar(150)
)
AS
UPDATE [T_SetupSheetHistoryOrderNotes]
SET
[T_SetupSheetHistoryOrderNotes].OrderNotes=@Reason + [T_SetupSheetHistoryOrderNotes].OrderNotes
FROM [T_SetupSheetHistoryOrderNotes]
WHERE [T_SetupSheetHistoryOrderNotes].WOID=@WOID


Michael
For all your DNC needs for your CNC machines. www.mis-group.com

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2005-06-25 : 15:03:16
Is OrderNotes a TEXT or NTEXT column?

Mark
Go to Top of Page

mistux
Yak Posting Veteran

90 Posts

Posted - 2005-06-25 : 15:13:03
It is NTEXT.

Michael
For all your DNC needs for your CNC machines. www.mis-group.com
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2005-06-27 : 04:30:42
That explains it - Look up UPDATETEXT in BOL.
Go to Top of Page

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2005-06-27 : 13:25:43
Or you can change it to varchar(8000). Or will it need to be bigger than 8000?

Brenda

If it weren't for you guys, where would I be?
Go to Top of Page

mistux
Yak Posting Veteran

90 Posts

Posted - 2005-06-27 : 13:57:46
OK, thanks that looks liek what I want, now I just have to get the syntax correct.

Is this correct?

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

The 0 is for inserting my @Reason data at the top.


Michael
For all your DNC needs for your CNC machines. www.mis-group.com
Go to Top of Page
   

- Advertisement -