Sybase SQL update column with pattern

Posted on 2011-10-24
Last Modified: 2012-05-12

I want to update a table use a pattern for example:

update products set productid = "productid/productid" where productid =  "productid-productid

Is that possible?

From example:
id, productid,price
1, 100-1,1

To example:
id, productid,price
1, 100/1,1

Question by:africanw
    1 Comment
    LVL 24

    Accepted Solution

    You don't tell us which Sybase database product or version you're using, which is a problem because the answer will be different depending on which you're using.

    Assuming you are using Sybase ASE with version at least, this is easy:

    update products
    set       productid = str_replace(productid, "-", "/")
    where  productid like "%-%"

    If your products table is very large you may need to batch this into smaller updates to avoid filling your transaction log.

    If you're using a different version of ASE, or you're not using ASE, let us know as the answer will probably have to change.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now