• Luis Cazares - Tuesday, October 17, 2017 1:50 PM

    Did you find a real-world problem with this functionality? Or were you experimenting?

    Thanks for the reply Luis. Curiosity. It started as a work related problem - I replaced some charindex logic with patindex logic. Occasionally we'd get some instances of charindex('',''). After switching to patindex I got some 1's where I was expecting 0's. It was frustrating but, once I figured that patidex('','')=1 the problem was easy to fix.

    Chris & SQL Pirate - Thanks to you both - I get it now. My real question (looking back I worded my question poorly) was, why does charindex('','') not equal patindex('','')
    Part of the my confusion was - if patindex('','')=1 then why does charindex('','') not equal 1? Nonetheless, you guys were both very helpful.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001