0

I have a table with a field with values stored in the "STANDARD,ELITE,DELUXE" format. I want to find all the rows where this field contains a defined value, e.g. ELITE or ELITE,DELUXE.

How can I perform a query in MSSQL SERVER to search a value in a field like this one?

Any help would be highly appreciated.

Thank you,

Fazil Mir
  • 783
  • 2
  • 9
  • 23
  • 1
    The *real* question is why are you storing delimited data in your database in the first place? Fix the design, fix the problem. – Thom A Sep 17 '21 at 11:14
  • @Larnu Actually I don't want to make multiple entries for the same record just because of a single column. There can be more than 10-20 delimited values in a field. If I make different entries for each one of them, it won't be suitable. Please correct me if I am wrong. Is there any other better way to achieve this task? – Fazil Mir Sep 17 '21 at 11:19
  • *"Please correct me if I am wrong."* You are. You are breaking the fundamental principles of normalisation. A value should represent one atomic value, and `STANDARD,ELITE,DELUXE` is 3 atomic values. You really need to normalise your design here. *That* is the real solution. – Thom A Sep 17 '21 at 11:20
  • @Larnu thank you, I will make different entries. That would be simple and easy. – Fazil Mir Sep 17 '21 at 11:24
  • @FazilMir You could have a table that creates 1 row per value. I.e.: ID.Value 1.DELUXE 1.ELITE Add additional ID-columns as needed. I apologize about formatting. Not sure how to fix that in comments. – SchmitzIT Sep 17 '21 at 11:25
  • @SchmitzIT Thank you, I normalized it. It's working fine now. – Fazil Mir Sep 17 '21 at 11:35

0 Answers0