How do I create a stored procedure that will optionally search columns?

前端 未结 10 679
醉话见心
醉话见心 2020-12-08 08:30

I\'m working on an application for work that is going to query our employee database. The end users want the ability to search based on the standard name/department criteria

10条回答
  •  一整个雨季
    2020-12-08 09:12

    Erland Sommarskog's article Dynamic Search Conditions in T-SQL is a good reference on how to do this. Erland presents a number of strategies on how to do this without using dynamic SQL (just plain IF blocks, OR, COALESCE, etc) and even lists out the performance characteristics of each technique.

    In case you have to bite the bullet and go through the Dynamic SQL path, you should also read Erland's Curse and Blessings of Dynamic SQL where he gives out some tips on how to properly write dynamic SQLs

提交回复
热议问题