Delete multiple lines from SQL Server that have the same text snippet?

Asked

Viewed 290 times

0

To test my forms, I ran multiple fills with the word "test" in the fields. Now I wanted to clean the BD, but I’m having difficulties to delete several lines with the same text snippet "test"

I am applying the following command, but no line is affected.

Delete FROM [DB_ControleDemandas].[dbo].[formulario] where Datas = '%Teste%'
  • The correct syntax for your Where would be: Where Dates like '%Test%'

  • 1

    I knew it was simple, rs. Thank you!

1 answer

1


Using the command as described is trying to delete all lines with the text %Teste%. What you want here is to delete all lines containing the text 'Testing', regardless of where it is placed. The command to use is LIKE, as follows:

DELETE FROM [DB_ControleDemandas].[dbo].[formulario] WHERE Datas LIKE '%Teste%'
  • I knew it was simple, rs. Thank you!

  • @Danielgomes, it is worth marking the answer as accepted, if solved the problem ;) (why accept an answer)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.