Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query help

Author  Topic 

anjali5
Posting Yak Master

121 Posts

Posted - 2014-07-30 : 17:20:56
Hi All,

I have the following table:



SN date GCG SN date GS SN date CS_name SN date PN_name
1 12/23/2011 Goal Control Gate 23 12/23/2011 GOAL SECTION 56 12/17/2014 Cold Section 76 12/19/2011 Paint_ SECTION


Is it possible to get the values of this table based on a particular parameter so for e.g, If I pass "GOAl Control gate" as a parameter then can I get the value of SN, Date for "GOAl Control gate" . if the parameter value
is "GOAl Control gate" and "GOAl Section" then I want the value of SN, date for both "GOAl Control gate" and "GOAl Section".

I will be passing the value as comma delimited string
DECLARE @SECTION varchar(200)

I can pass the value as Goal Control Gate, GOAL SECTION to this stored procedure and get the SN and date for Goal Control Gate, GOAL SECTION , I don't want the value of Cold section and paint section in this case. If I pass the value Goal Control Gate , GOAL SECTION, Cold Section then I need the SN and date for all three of them.

I am using sql server 2005

So I want something like this
if I pass the value "Goal Control Gate" , "GOAL SECTION" in @Section parameter then I want the output like below in the same format



SN date GCG SN date GS
1 12/23/2011 Goal Control Gate 23 12/23/2011 GOAL SECTION


and if I am passing "Goal Control gate", "Goal Section", "Cold section" then I want the output like this


SN date GCG SN date GS SN date CS_name
1 12/23/2011 Goal Control Gate 23 12/23/2011 GOAL SECTION 56 12/17/2014 Cold Section


If I am passing "Goal Control gate", "Goal Section", "Cold section", "Paint Section" then I want the output like this



SN date GCG SN date GS SN date CS_name SN date PN_name
1 12/23/2011 Goal Control Gate 23 12/23/2011 GOAL SECTION 56 12/17/2014 Cold Section 76 12/19/2011 Paint_ SECTION

Any help will be appreciated.
   

- Advertisement -