locked
query like '%_%' not work RRS feed

  • Question

  • why i get following result

    SELECT *
      FROM [ESB2.1].[dbo].[FlowPatientExample]
      where 1=1 and CreateDate >'2020-06-30 00:00:00.000'
      --and nodeCode like '%CPOE040403%'
      and VisitNo  like '%_%'
      and VisitNo='2020092461'
      order by CreateDate desc

    Tuesday, June 30, 2020 7:16 AM

Answers

  • Try this pattern: ‘%[_]%’, and reconsider ‘and VisitNo=’2020092461’.


    • Marked as answer by Oscar_Wu Tuesday, June 30, 2020 8:02 AM
    • Edited by Viorel_MVP Tuesday, June 30, 2020 8:03 AM
    Tuesday, June 30, 2020 8:01 AM

All replies

  • The pattern ‘%_%’ means any character preceded and followed by zero or more characters. Seems similar to “not empty”.

    Which condition do you need?


    • Edited by Viorel_MVP Tuesday, June 30, 2020 7:54 AM
    Tuesday, June 30, 2020 7:51 AM
  • Thank you very much, i need to query data that contains '_' character. Thank you!
    Tuesday, June 30, 2020 7:55 AM
  • Try this pattern: ‘%[_]%’, and reconsider ‘and VisitNo=’2020092461’.


    • Marked as answer by Oscar_Wu Tuesday, June 30, 2020 8:02 AM
    • Edited by Viorel_MVP Tuesday, June 30, 2020 8:03 AM
    Tuesday, June 30, 2020 8:01 AM
  • it workded, thanks :)
    Tuesday, June 30, 2020 8:03 AM