Question : Search for Procedure SQL Server

How can I return values from the input from the user of the GUI>?  I need to have many tables joined based on what is handed into the Proc.

If they tell me i_Email = x then I have to return still first name, last name email and phone in the grid.  If they give me the Address and the email I have to return first name, last name email and phone too.  If they say i_firstName = x and i_email = y I have to return first name, last name email and phone.

Of all the fields that we have that are searchable if they hand me address, email, name, etc. I have to return a TON of data and want this procedure to be efficient to say the least.
How do I do this?

There are many approaches to say the least.   There is the dynamic SQL Server approach and the "basic join every single table" approach with a where clause where you can join to 20 tables even though you may only need 4 tables aspect.

What is the better approach>?

How do experts execute the search criteria procedure in SQL Server 2008?

Performance is the biggest deal.  We have several silos so you can get up to 20 tables joined at one time.

Please give me your thoughts experts!

Thanks so much for your help in advance,

B

Answer : Search for Procedure SQL Server

Hi cyimxtck,

I would suggest you to:
1. Identify the most commonly used joins and create them as VIEWs.
2. Create a basic query which joins every TABLEs and the VIEWs you created in 1.
3. Generalize few most commonly used JOINs and create separate queries for them.
4. Put 2. & 3. together and wrap them with IF checking statement.

Random Solutions  
 
programming4us programming4us