Question

Locked

Charindex in SQL Update Statement

By martinbullock15 ·
Hi

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

Martin

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums