sql query to check 's

Answered sql query to check 's

  • Friday, February 01, 2013 3:06 PM
     
     

    hi

    i have name like david's  i need to check this in where clause or with like

    how to do it in sql

All Replies

  • Friday, February 01, 2013 3:12 PM
     
      Has Code
    DECLARE @tab TABLE(NAME VARCHAR(10))
    INSERT INTO @tab
    SELECT 'abc''s' UNION ALL
    SELECT 'abcdef''s' UNION ALL
    SELECT 'lmn''s' UNION ALL
    SELECT 'pqr''s'
    SELECT * FROM @tab
    SELECT *
    FROM @tab
    WHERE NAME LIKE 'abc''s'


    Narsimha

  • Friday, February 01, 2013 3:12 PM
     
     Answered Has Code

    You just double up the single quote:

    Declare @tvTable Table (
    	DataCol varchar(10)
    )
    
    Insert	@tvTable
    Values	('blip'), ('blop'), ('flip''s'), ('flop''s')
    
    Select	*
    From	@tvTable
    Where	DataCol Like '%''%'

  • Friday, February 01, 2013 3:13 PM
     
     

    itas not  like that

    its  like  abc's product,

    abced's product

    something liek this

  • Friday, February 01, 2013 3:13 PM
     
      Has Code

    select * from person where lastname = 'david''s' select * from person where lastname like '%''%'


  • Friday, February 01, 2013 3:21 PM
     
      Has Code

    itas not  like that

    its  like  abc's product,

    abced's product

    something liek this

    Try

    SELECT *
    FROM @tab
    WHERE NAME LIKE ('abc''s%')


    Narsimha

  • Friday, February 01, 2013 7:20 PM
     
     Proposed
    SELECT * FROM yourtable WHERE yourcolumn LIKE '%''%';
    • Proposed As Answer by AccDba111 Friday, February 01, 2013 8:25 PM
    •  
  • Friday, February 01, 2013 8:19 PM
     
     

    SELECT *

    FROM <Your Table > where <Fields> LIKE '%Your Desired O/P%'