Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Posts
    5

    Unanswered: NEED Query to find apostrophes in table

    I've tried everything I can think of to find all the records in a table column (lastname) that contain an apostrophe. I know they are there (O'Brian, D'Marcus, etc.) However, I keep getting syntax errors.

    Could someone PLEASE help?!!

    Thanks,
    Karen

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    SELECT *
       FROM theTableWithTheUnspecifiedName
       WHERE lastName LIKE '%''%'
    -PatP

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Either way

    Code:
    USE Northwind
    GO
    
    SET NOCOUNT ON
    CREATE TABLE myTable99(Col1 varchar(80))
    CREATE INDEX IX1 ON myTable99(Col1)
    GO
    
    INSERT INTO myTable99(Col1)
    SELECT 'abc' UNION ALL
    SELECT 'a''c' UNION ALL
    SELECT 'xyz'
    GO
    
    SELECT * 
      FROM myTable99
     WHERE LEN(Col1) <> LEN(REPLACE(Col1,CHAR(39),''))
    GO
    
    SELECT * 
      FROM myTable99
     WHERE Col1 LIKE '%''%'
    GO
    
    SET NOCOUNT OFF
    DROP TABLE myTable99
    GO
    ....it's a scan. I wonder if one would be more effecient than the other though
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  4. #4
    Join Date
    Dec 2005
    Posts
    5
    Works fine.

    Many thanks!!!!!

    Karen

Posting Permissions

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