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.
| Author |
Topic |
|
Hariarul
Posting Yak Master
160 Posts |
Posted - 2006-09-06 : 02:32:01
|
| Hi All, I have a database with very heavy volume of data.I need to write a stored procedure with 20 parameters as input and it searches in a table . Most of the parameters or NULL , how do I write this procedure without using any dynamic queries.Ex : To find a customer I have a proc which can accept 20 parameters like CustName, City, State , Phone , Street etc.Im passing only Custname as parameters and other 19 parameters are NULL.How do I write the WHERE clause ?Thanks in advance,HHA |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-06 : 02:41:52
|
| select ct.* from customertable ctwhere (@customername is null or ct.customername = @customername)and (@param2 is null or ct.col2 = @param2)and (@param3 is null or ct.col3 = @param3)and (@param4 is null or ct.col4 = @param4)and ...Peter LarssonHelsingborg, Sweden |
 |
|
|
Hariarul
Posting Yak Master
160 Posts |
Posted - 2006-09-06 : 02:54:35
|
| Thanks |
 |
|
|
|
|
|