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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 IF EXISTS....

Author  Topic 

anandc
Starting Member

20 Posts

Posted - 2005-10-04 : 07:47:33
I have written the below statement in a stored proc

IF EXISTS(SELECT DummyCol FROM DummyTbl)....

when i am running this SP it gives me the proper result but all the records returned by "SELECT DummyCol FROM DummyTbl" statement are also shown in the Query Analyser window. why is it so? will this cause any performance problems in my application??

Thanks
- Anand

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-10-04 : 07:51:06
should not unless you have that query in another part of your script

also you might want to modify it a bit
IF EXISTS(SELECT * FROM DummyTbl)....

and add a filter thru where clause?


--------------------
keeping it simple...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-04 : 07:51:44
It will show the result if you run it in the Query Analyser
I dont think there is performance issue
Can you post the full code and give more details?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

anandc
Starting Member

20 Posts

Posted - 2005-10-04 : 08:13:15
Here is the part of code.....

IF NOT EXISTS(
SELECT IntErrorId FROM AppError
WHERE IntRemitId = @intRemitId AND
IntTransId = @intTransId AND
IntErrorId = @intErrorId AND
ISNULL(ErrorSkipInd, 'N') = 'N' AND
ISNULL(FixedInd, 'N') = 'N'
)
BEGIN
INSERT INTO AppError(IntRemitId, IntTransId, IntErrorId, FileIndexID, AttributeNm, ReqValue,
ActualValue, Remarks, ErrorSkipInd, SkippedBy, SkippedDate, FixedInd, CreatedBy, CreatedDt, ModifiedBy, ModifiedDt)
VALUES( @IntRemitId, @intTransId, @intErrorId, @strFileIndexID, @strAttributeName, @strReqValue,
@strActualValue, @strRemarks, @chrErrorSkipInd, @intSkippedBy, @dtmSkippedDate, 'N',
@IntUserId, getDate(), @IntUserId, getDate() )
END

- Anand
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-04 : 08:51:36
It is strange
Is this your full code?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

anandc
Starting Member

20 Posts

Posted - 2005-10-04 : 10:14:34
Hi Madhivanan

This is just a part of the code....the variables used has been assigned values in the code above this one....could you pls. let me know what is wrong with this ??

- Anand
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-04 : 10:17:22
If other part of code has Select Statements then those will be returned if you run the sp
Why dont you post full code?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -