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 2005 Forums
 Transact-SQL (2005)
 Stopprocedure and return Output

Author  Topic 

shapper
Constraint Violating Yak Guru

450 Posts

Posted - 2007-02-12 : 10:34:59
Hello,

Inside a stored procedure I have an IF condition.

I want to set an output variable to -1, return it and not execute the rest of the code (which would insert a record in a database) if the condition verifies.

How can I do this?

Thanks,
Miguel

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-02-12 : 10:38:01
[code]If <some-condition>
Begin
Set @outvar = -1
Return
End
Else
Begin

-- do whatever you want
End
[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-12 : 10:38:08
if something
begin

select yourOutParam = -1
return

end



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-12 : 10:38:33
awww.... by 7 seconds





Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -