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 |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2009-07-30 : 16:21:56
|
| There are two tables. There is no joint field between them. User input search parameter into tParameters.The following code is working fine. How to write a function to reurn where sentence so that I can pass parameter to replace the table like tParameters and a column like Type.SELECT OrderDate, TypeFROM tOrder AS OWHERE (O.Type LIKE 'N%' AND EXISTS(SELECT * FROM tParameters AS P WHERE P.Type = ' ')) OR (NOT EXISTS(SELECT * FROM tParameters AS P WHERE P.Type = ' ') AND EXISTS(SELECT * FROM tParameters AS P WHERE P.Type = O.Type)); |
|
|
|
|
|