sql - Is there a way to exec a SP, check the result with an if statement and return the value, all within just one line? -


i know works know of way of doing these in one line of code:

exec @resultint = nameofastoredprocedure if @resultint <> 0 return @resultint 

like:

-- i'm trying not work want in -- 1 line find-replace throughout our code base if (exec @resultint = nameofastoredprocedure) <> 0 return resultint  

maybe i'm getting wrong, why not removing whitespaces?

exec @resultint = nameofastoredprocedure if @resultint <> 0 return @resultint; 

if want have in 1 line easier editing, should work. include declaration of @resultint:

declare @resultint int; exec @resultint = nameofastoredprocedure if @resultint <> 0 return @resultint; 

tested ms sql 2005.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -