Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to Use If Not 0 then....

Status
Not open for further replies.

KOVMoe

Programmer
Jun 30, 2004
34
US
I am using this code in a stored procedure:

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

SELECT C6.OCR_ID_NR,C6.OCR_STS_NR,E2.LOC_NA, C6.OCR_NA, C6.OCR_DT, C6.TEM_ID_NR,
C6.OTH_TEM_ID_NR, C6.DIS_LOC_SYS_NR, C6.CO_ID_NR,
C6.OCR_CDN_EMP_NR,D8.SVP_ID_NR,
C3.MSG_ID_NR, C3.OCR_ID_NR, C3.MSG_CMT_TE, C3.MSG_EXP_DT, C3.SVP_ID_NR
FROM TTIXMSG_WLCMMSG C3
INNER JOIN TTIXOCR_EVENTINFO C6 ON C3.OCR_ID_NR = C6.OCR_ID_NR
INNER JOIN TTIXSVP_MSGAUD D8 ON C3.SVP_ID_NR = D8.SVP_ID_NR
INNER JOIN TTIXTVI_TEMVENINF E2 ON C6.LOC_ID_NR = E2.LOC_ID_NR

WHERE D8.SVP_ID_NR IN ('1','2','3')
AND C6.DIS_LOC_SYS_NR = @intDisNr

The last line are what I need to check.

if @intDisNr <> '10 or '20'
then
AND C6.DIS_LOC_SYS_NR = @intDisNr


But that does not work,
Any ideas????

[king] KOVMoe

Thank you,

[king]Moe-King of the Village Idiots.

"When in trouble,
when in doubt;
Run in circles-
SCREAM & SHOUT!!"
Burma Shave
 
I this the entire procedure? Where is @intDisNr
declared?

is this line correct?
if @intDisNr <> '10 or '20'

because you are missing a ' after '10

what are you trying to do with @intDisNr ? assign a value to it? or read a value from it?

George Oakes
Check out this awsome .Net Resource!
 
Your requirements are somewhat unclear but it is possible to do with something like

Code:
WHERE D8.SVP_ID_NR IN ('1','2','3')
and (( @intDisNr not in('10','20') 
  and C6.DIS_LOC_SYS_NR = @intDisNr)
or @intDisNr in('10','20')
 
Sorry,
here is the entire sproc:

CREATE PROCEDURE [dbo].[spBusinessDevelopment_TicketTracker_AdminWlcmMsg_Index]


@intModuleID INT=0,
@intUserID INT=0,
@intLocationLevelID INT=0,
@intLocationID INT=0,
@intLocationID_Top INT=0,
@intDisNr INT=0,
@strReturnMessage varchar(100) out

AS
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

SELECT C6.OCR_ID_NR,C6.OCR_STS_NR,E2.LOC_NA, C6.OCR_NA, C6.OCR_DT, C6.TEM_ID_NR,
C6.OTH_TEM_ID_NR, C6.DIS_LOC_SYS_NR, C6.CO_ID_NR,
C6.OCR_CDN_EMP_NR,D8.SVP_ID_NR,
C3.MSG_ID_NR, C3.OCR_ID_NR, C3.MSG_CMT_TE, C3.MSG_EXP_DT,
C3.SVP_ID_NR
FROM TTIXMSG_WLCMMSG C3
INNER JOIN TTIXOCR_EVENTINFO C6 ON C3.OCR_ID_NR = C6.OCR_ID_NR
INNER JOIN TTIXSVP_MSGAUD D8 ON C3.SVP_ID_NR = D8.SVP_ID_NR
INNER JOIN TTIXTVI_TEMVENINF E2 ON C6.LOC_ID_NR = E2.LOC_ID_NR
WHERE D8.SVP_ID_NR IN ('1','2','3')
and @intDisNr not in('10','20')
and C6.DIS_LOC_SYS_NR = @intDisNr
GO

I wnat to show everything if the user has a @intDisNr 0f 10 or 20, then
show only thier container if they have a numebr such as 6, or 9, or 12.

Thanks.

Thank you,

[king]Moe-King of the Village Idiots.

"When in trouble,
when in doubt;
Run in circles-
SCREAM & SHOUT!!"
Burma Shave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top