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 - scanning of parameters

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-06 : 05:39:03
Hi all. I have a problem on my query. let me explain first the scenario.

I have a windows application project that views a report through report viewer(Report of all employees that have a religion of adventist, born again, catholic, baptist, etc....). In my windows application, I have checkboxes for a specific religion. So, if I checked baptist and catholic, report generated is all employee that has religion of baptist and catholic.

My concern is, How could i make a query of this?

sample tables.
table - employee
dcno name religion
1 jon baptist
2 rose catholic
3 joy baptist
4 mike adventist
5 soy born again
6 rich protestant

you can supply additional table if needed.

thanks
-Ron-

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-06 : 05:41:29
What is wrong with the answers you got here?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=79982


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-06 : 05:44:49
Why didn't you present your full problem the first time?
Do you like to have us spend more time on you?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-06 : 05:47:21
Ah ok. what i want is, parameter is dynamically created. The number of parameters will depend on the input of the user. If the user checked born again, protestant, and catholic,,, the result is all employees that have religion like this.

I think I made it clearer to you.
thanks
-Ron-
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-06 : 05:49:30
Yes, but you haven't answered my somewhat rhetorical questions...
The obvious counter-question is "how do you pass the selected religions to the stored procedure"?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-06 : 06:00:21
Ok. interaction of windows application and sql. C# windows application can manage to pass parameters to sql through reporting services. I just don't know how the procedure can catch the parameters but i think it can be.
Is it possible that the parameter can be dynamically created?

thanks
-Ron-
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-06 : 06:11:38
Reporting services?
There is a forum for that too
http://www.sqlteam.com/forums/forum.asp?FORUM_ID=35


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-06 : 06:48:35
I got the answer. yewehhhhh.
peso thanks for your time.
KH i highly appreciate your help. I got the answer here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80004

what i did is, in windows application i concatenate the selected religion seperated by a comma, and i passed it to @empreligion.

DECLARE @religion varchar (100)
SET @religion = @empreligion

select D.fullname, P.religion, E.empno
from pspersonaldata as P
inner join hremployees as E on P.dcno = E.empdcno
inner join psdatacenter as D on D.dcno = E.empdcno
inner join CSVTable(@religion) as R on P.religion = R.stringval

Thanks KH.
-Ron-
Go to Top of Page
   

- Advertisement -