Advanced Query Help

Phil_b

Registered User.
Local time
Today, 01:29
Joined
Oct 7, 2005
Messages
30
The below Stored Procedure was refined to incorporate a UDF. My problem now is that I need it to be even more dynamic. I ideally need the user to have the option to select which fields are incorporated into the query. I have the front end framework although not sure currently how to make field selection dynamic...

CREATE PROCEDURE dbo.sp_ClientQuery

(
@inputRegion varchar(500),
@inputPub varchar(500),
@inputCountry varchar(500)
)

AS


SELECT dbo.tblClient.Country, dbo.tblClient.cName, dbo.tblClient.clientID, dbo.tblClient.Wholename, dbo.tblClient.TelNumberG, dbo.tblClient.TelNumberD, dbo.tblClient.City, dbo.tblPublication.pName
FROM dbo.tblOrders INNER JOIN
dbo.tblClient ON dbo.tblOrders.clientID = dbo.tblClient.clientID INNER JOIN
dbo.tblPublication ON dbo.tblOrders.id = dbo.tblPublication.id
WHERE (dbo.tblClient.Region IN (select value from fnSplit(@inputRegion,',') )) AND
(dbo.tblPublication.pName IN (select value from fnSplit(@inputPub,',') )) AND
(dbo.tblClient.Country IN (select value from fnSplit(@inputCountry,',') ))
GO


This is becoming pretty complicated so any help appreciated.

Phil
 
Why not return all the columns and just use the ones you want at the time?
 

Users who are viewing this thread

Back
Top Bottom