November 10, 2009 at 1:00 pm
I have a script that scrubs a single field in a table and I would like to update that same field in that same table but I am at a loss of how I would do it. The basic script is the following:
select DISTINCT SUBSTRING([MyField],
CHARINDEX('/', [MyField])+1, 15) as mfield from
MyTable
UPDATE MyTable
SET [MyField] = ????
November 10, 2009 at 1:03 pm
Can you post exactly what your need is? It looks like you want to select the 15 characters after a "/", is this correct? If your SELECT statement is correct you could just take the expression from the SELECT and put is in the UPDATE if you want to update every row in the table to the new value.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
November 12, 2009 at 9:43 am
Jack Corbett (11/10/2009)
Can you post exactly what your need is? It looks like you want to select the 15 characters after a "/", is this correct? If your SELECT statement is correct you could just take the expression from the SELECT and put is in the UPDATE if you want to update every row in the table to the new value.
I posted everything. Yes that is what I need to do. Can you please assist with the script?
November 12, 2009 at 9:53 am
UPDATE MyTable
SET [MyField] = SUBSTRING([MyField], CHARINDEX('/', [MyField])+1, 15)
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply