Home > Software design >  MS SQL - find out if a field exists within another
MS SQL - find out if a field exists within another

Time:09-16

I have a table that, among its columns, has two particular char columns: "Code" and "Obs".

For example:

Column1 Code Obs
aaa 123 This customer's code is 123

How do I find this record, based on the fact that the info on column "Code" is present in the info on column "Obs"?

Thank you JD

CodePudding user response:

One option is to use charindex:

SELECT *
FROM   mytable
WHERE  CHARINDEX(code, obs) > 0
  • Related