update using a wildcard

  • is it possible to update values based on a wildcard? For instance, I have many dates in the database that are all formatted with different criteria and I want them all to be MM/DD/YYYY. To make things a little different, the value inside of this field can represent anything, not just a date. I want to update only the values that hold a mis-formatted date.

    So I do a query:

    select distinct IndexFieldText from dbo.DocumentField where IndexFieldText like '%/_/%'

    This will bring back only the date values that have a single digit day.

    Can I update these values using an update query with a wildcard such as:

    update dbo.tablename set IndexFieldText='%/0_/%' where IndexFieldText like '%/_/%'

  • support-555807 (8/22/2012)


    is it possible to update values based on a wildcard? For instance, I have many dates in the database that are all formatted with different criteria and I want them all to be MM/DD/YYYY. To make things a little different, the value inside of this field can represent anything, not just a date. I want to update only the values that hold a mis-formatted date.

    So I do a query:

    select distinct IndexFieldText from dbo.DocumentField where IndexFieldText like '%/_/%'

    This will bring back only the date values that have a single digit day.

    Can I update these values using an update query with a wildcard such as:

    update dbo.tablename set IndexFieldText='%/0_/%' where IndexFieldText like '%/_/%'

    no, you cant

    try to use like this

    update dbo.tablename

    set IndexFieldText=STUFF(IndexFieldText, patindex('%/_/%', IndexFieldText), 1, '/0')

    where

    IndexFieldText like '%/_/%'

    a refinement of what should be with the data like 01/02/qwerty/02?

    I Have Nine Lives You Have One Only
    THINK!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply