Problem related to deletion of data from table using like key word

  • I have a parameterised query

    here I pass one parameter

    In query parameter name @path.

    Now I want to delete record from the table which will have @path as substring...

    How to do this?

    I tried it as

    delete tableName where path like '''%'+@path +'%'''

    This did not worked

    Note tableName is table in my database and path is one of column in that table

    I want to delete entry by checking substring

  • you've missed out the FROM

    delete FROM tableName where path like '''%'+@path +'%'''

    try to see if it will delete the correct record using a select statement first to test.

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

  • I tried it like that but it did not work.....

    Actually i want to delete the record which will have @path as as substring in path........

    example

    suppose tableName contain entries as

    ID path Value

    1 server 3

    2 deever 8

    3 version 9

    4 central 5

    Now suppose if i supplied @path = 'ver'

    I want to delete all the records from the table which will have @path as substring in path column

    How to do this?

    please help

  • Get rid of your extra quotes.

    delete FROM tableName where path like '%'+@path +'%'

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Thanks Garadin...........

    Problem is solved.....

  • Thanks for the feedback sar_kan25. Glad we could help.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

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