November 30, 2006 at 8:02 am
I am trying to update part of a char(50) field, and am having a lot of difficulty with the syntax. I'm trying to update positions 37, 4 and 41, 4 with zeros if a certain condition is met in a different field in the table. I've been trying to set the field as follows:
SET SUBSTRING(ADDITIONALDATA,37,4) = '0000' but it seems to have a problem near the '('.
Thanks
November 30, 2006 at 8:39 am
That syntax works only in VB. You need to do something like this :
UPDATE dbo.Table set ColName = LEFT(ColName, 36) + '0000' + RIGHT(ColName, 14) where...
November 30, 2006 at 8:54 am
THANK you very much! That seems to have worked.
December 1, 2006 at 6:29 am
The STUFF function might also help.
UPDATE table
SET AdditionalData = STUFF(AdditionalData,37,4, '0000')
WHERE certaincondition = 1
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply