Results 1 to 5 of 5

Thread: [RESOLVED] quick query question

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Resolved [RESOLVED] quick query question

    Is there a quick way to return all records for a certain field contains any character that is NOT alphanumeric?

    I'm changing the rules on a field in my table, and I could pull all the records and run them through code to clean them up, but then I was wondering if there were a quick way to find just those records that need changing.

    select * from Table1 where [any character in Column1] not in/like 'ABC..abc..123'

    I'm guessing not, unless maybe with Regular Expressions.

    This is for Access by the way.
    Thanks.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: quick query question

    SQL Server 2008
    Code:
    declare @temp table(data char(1))
    
    INSERT @temp (data) values
    ('a'),('@'),('1'),('.')
    
    select *
    from @temp
    where data not like '[A-Z0-9]'
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  3. #3

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: quick query question

    Sorry , it isn't perfectly clear to me.
    For one thing, this is an Access database. So does that expression work? It looks like a regular expression, but I haven't tried that in Access.

    But the other thing, it looks like your data is all char(1)
    my data is a string up to 255 characters and I want to find any that contains a non-alphanumeric anywhere in the string
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  4. #4
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: quick query question

    It looks like Access does support the like operator. http://office.microsoft.com/en-us/ac...001032253.aspx
    Since your data contains more than one character, try using the wild card:
    Code:
    where data not like '*[A-Z0-9]*'
    or
    Code:
    where data like '*[!A-Z0-9]*'
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  5. #5

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: quick query question

    First one doesn't work, returns no records

    Second one was exactly right. Thanks. Final query

    where data like '*[!A-Za-z0-9]*'

    That cuts 25000 records down to 179.
    Thanks a lot.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width