SQLTeam.com | Weblogs | Forums

Subtract the amount over?

Hello I'm trying to come up with a query that will subtract the overage from a column. I have a table that has a column sku and sometime the update has a greater amount than 15, and that the limit that we can use. So far I'm using this:

UPDATE updatepos
SET sku = left(sku, LEN(sku) - 2)
WHERE (LEN(sku) > 15)

but the over amount varies so that doesn't work all the time. How could I get it to subtract the amount that it's over 15?

Thanks for any help.

Please proved some sample data and expected output (from your provided sample data).

UPDATE updatepos
SET sky = LEFT(sku, 15) 
WHERE LEN(sku) > 15;

Why not do it this way if you are always removing anything over 15.

That work great, thanks!