Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

easiest way to automatically append to a text field?

Status
Not open for further replies.

joeshow

MIS
Jun 18, 2001
1
US
What is the easiest way to append the same message to the end of a text field every time an end-user creates/updates a record?
 
If the column is text or ntext data type you'll need to use UPDATETEXT as in the following example from SQL BOL.

USE pubs
GO
EXEC sp_dboption 'pubs', 'select into/bulkcopy', 'true'
GO

DECLARE @ptrval binary(16)
SELECT @ptrval = TEXTPTR(pr_info)
FROM pub_info pr, publishers p
WHERE p.pub_id = pr.pub_id
AND p.pub_name = 'New Moon Books'
UPDATETEXT pub_info.pr_info @ptrval null null 'The text to insert....'
GO

EXEC sp_dboption 'pubs', 'select into/bulkcopy', 'false'
GO

If the column data type is char, varchar, nchar or nvarchar then use an UPDATE query and the concatenation operator (+).

Update Pub_info Set pr_info= pr_info + ' The text to insert...'
where pub_id = 12 Terry

"I'm not dumb. I just have a command of thoroughly useless information." - Calvin, of Calvin and Hobbes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top