Web Development



Charindex in SQL Update Statement

By martinbullock15 ·

How can i put this in to a SQL Update statement:

(substring([STKNAME2],(-2),(charindex('-',[STKNAME2]) + 5)))

I have tried this but it updated no rows:

UPDATE [tbl]
SET [field1] = (substring([field2],(-2),(charindex('-',[field2]) + 5)))
WHERE [field3] = [value] AND
[field4] = [value]

I have put the substring statement directly into the SQL table design as a computed column (which worked) but i need to be able to change the final value (+5) depending on the WHERE clause.

Thanks in advance for any help


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Related Discussions

Related Forums