June 16, 2015 at 2:15 pm
I'm confused, as I am trying to erase some erroneous bad data in my table. The description column has a lot of </div>oqwiroiweuru</a> weird data attached to it, i want to keep the data to the left of where the </div> erroneous data begins
update MyTable
set Description = LEFT(Description(CHARINDEX('<',Description)-1)) where myid = 1
that totally works.
update MyTable
set Description = LEFT(Description(CHARINDEX('<',Description)-1)) where myid >= 2
gives me a Invalid length parameter passed to the LEFT or SUBSTRING function. The statement has been terminated error
??
arch
June 16, 2015 at 2:24 pm
there's no guarantee that EVERY row contains the search term, so you need to include that check in your WHERE.
update MyTable
set Description = LEFT(Description(CHARINDEX('<',Description)-1))
where CHARINDEX('<',Description) > 0
AND myid >= 2
Lowell
June 16, 2015 at 2:36 pm
Thanks, that rocks :-D:-D
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply