June 11, 2013 at 9:18 am
Hello,
I am new to tsql coding and I am in the process of adding a piece of code to an already existing stored proc. Here is my code
select @Count1=count(*) from [test] where [testcol] = 10
select @Count2=count(*) from [test1] where [testcol] = 10
if @Count1>0 or @Count2>0
then exit the storedproc and dont process any further code in the stored proc. If only the condition fails above the stored proc shd be process. How do I achieve this?
Thanks
June 11, 2013 at 9:28 am
It's really easy
select @Count1=count(*) from [test] where [testcol] = 10
select @Count2=count(*) from [test1] where [testcol] = 10
IF @Count1<=0 AND @Count2<=0
BEGIN
-- Your SP code here
END
June 11, 2013 at 9:31 am
DBA24 (6/11/2013)
Hello,I am new to tsql coding and I am in the process of adding a piece of code to an already existing stored proc. Here is my code
select @Count1=count(*) from [test] where [testcol] = 10
select @Count2=count(*) from [test1] where [testcol] = 10
if @Count1>0 or @Count2>0
then exit the storedproc and dont process any further code in the stored proc. If only the condition fails above the stored proc shd be process. How do I achieve this?
Thanks
Maybe something like this:
select @Count1=count(*) from [test] where [testcol] = 10
select @Count2=count(*) from [test1] where [testcol] = 10
if @Count1>0 or @Count2>0
begin
return
end
else
begin
-- carry on
end
June 11, 2013 at 9:34 am
errr.. actually you want luis's given your requirements.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply