• The posted procedure is interesting in itself, but does not match the execution plans. We need the code for GetDMSDocumentInformationForSearch, not the procedure that calls it.

    By the way, you really need to read Erland Sommarskog's guide to writing dynamic search conditions:

    http://www.sommarskog.se/dyn-search.html

    In fact, I would suggest you read and understand that article fully before doing anything else today. 😉

    Paul