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)
 conditional execution

Author  Topic 

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2006-09-14 : 09:49:00
how do I test that several variables i am using match up with values in a table as a means Quality assurance. If the values do not match, then I want the SP to end itself. The code below is obv. incorrect, but it will give an idea as to what I am going for....

CREATE PROCEDURE sp1
@1 VARCHAR(50),
@2 FLOAT,
@3 FLOAT
AS
IF @1 = colA and @2 = colB
FROM tbl
WHERE @3 = colC
BEGIN
execute MY code
else
begin
terminate the SP
END
GO

Any help would be apperciated.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-14 : 10:00:24
If exists(Select * from table where colA=@1 and colB=@2 and colC=@3)
Execute the code

Madhivanan

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

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2006-09-15 : 08:44:55
thanks.
Go to Top of Page
   

- Advertisement -