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 |
|
debradeng
Starting Member
46 Posts |
Posted - 2006-10-20 : 03:50:03
|
| I have two queries,they have same functiion,that is to select same data from same joined tables.The only difference is they need different parameters.Query1:Select ... from...where (table1.field1=@param1)AND(table2.field3=@param2)Query2:Select ... from...where (table2.field1=@param1)I get a feeling that I can create one SP to perform these two queries.But I don't know how to do.Anybody has some suggestions?Thank you! |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-10-20 : 04:41:26
|
| [code]If (some condition) Select .... From .... where (table1.field1=@param1)AND(table2.field3=@param2) -- query 1Else Select .... From .... where (table2.field1=@param1) -- query 2End[/code]???Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
debradeng
Starting Member
46 Posts |
Posted - 2006-10-20 : 21:27:53
|
| Thank you, Harsh_athalye.Maybe I did not make myself clear,but good to know the "IF...Else.." idea!I really appreciate! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-21 : 01:25:01
|
| Make sure you followIf ...Begin..........EndElseBegin..........EndMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|