|
Email lists >
aspnet at aspadvice.com >
[aspnet] RE: SQL GURU: IN operator with Case Statement >
[aspnet] RE: SQL GURU: IN operator with Case Statement
[aspnet] RE: SQL GURU: IN operator with Case Statement
This post if a part of this thread
|
2008-06-10 12:02:58 |
|
|
RE: SQL GURU: IN operator with Case Statement
|
|
|
I like this one. However, I did get it running using the Where clause.
Subject: [aspnet] RE: SQL GURU: IN operator with Case Statement Date: Tue, 10 Jun 2008 09:53:21 -0700 From: Keith.Barrows watsonwyatt.com To: aspnet aspadvice.com
Not necessarily (though I like Penton's solution).
CREATE PROC myProc parm int = 0 -- Default parm to 0 if nothing is passed in
AS
BEGIN
problem with this is, if the user submits a parm, then it has to be used in the where clause. I added a value of "0" with text "-All-" in the page drop down in the first index before the 3 hard-coded codes. So, that's why I'm checking for parm = 0.
Date: Tue, 10 Jun 2008 11:56:38 -0400 From: terri.morton gmail.com To: aspnet aspadvice.com Subject: [aspnet] RE: SQL GURU: IN operator with Case Statement
But you could do a LEFT OUTER JOIN:
declare tbl TABLE( intCodes INT) INSERT tbl select 123INSERT tbl select 456INSERT tbl select 789 SELECT blah, blahFROM tblBlahLEFT OUTER JOIN tbl ON tblBlah.intField = tbl.intCodesWHERE tbl.intcodes IS NOT NULL OR param = 0 FWIW, I always recommend these great articles by Erland Sommarskog on Arrays and Lists in SQL Server: http://www.sommarskog.se/arrays-in-sql-2005.html http://www.sommarskog.se/arrays-in-sql-2000.html
On Tue, Jun 10, 2008 at 11:45 AM, Tim Curtin < tjc_tek  hotmail.co m">tjc_tek hotmail.com> wrote:
--- List Settings --- http://aspadvice.com/lists/
Enjoy 5 GB of free, password-protected online storage. Get Windows Live SkyDrive. --- List Settings --- http://aspadvice.com/lists/
Notice of Confidentiality
This transmission contains information that may be confidential. It has been prepared for the sole and exclusive use of the intended recipient and on the basis agreed with that person. If you are not the intended recipient of the message (or authorized to receive it for the intended recipient), you should notify us immediately; you should delete it from your system and may not disclose its contents to anyone else.
This e-mail has come to you from Watson Wyatt & Company. --- List Settings --- http://aspadvice.com/lists/
Now you can invite friends from Facebook and other groups to join you on Windows Live™ Messenger. Add them now!
--- List Settings ---
http://aspadvice.com/lists/
|
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|