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.
| Author |
Topic |
|
carmitage
Starting Member
8 Posts |
Posted - 2008-11-03 : 11:53:08
|
| How can I exit a stored procedure within a case statement? This doesn't work, but for example within a stored procedure:selectcase when count(*) > 1 then begin 'Display a message' RETURN end else 'Display a different message' end from alm.dbo.ANALYSIS_TEMP |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-11-03 : 11:55:15
|
| you can't exit it in the case statement.explain in more detail what your objective is and we can suggest other approaches._______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.1 out! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-03 : 11:56:19
|
| the statement itself is wrong it should be this i guessif (select count(*) from alm.dbo.ANALYSIS_TEMP) > 1 'Display a message'else'Display a different message' |
 |
|
|
carmitage
Starting Member
8 Posts |
Posted - 2008-11-03 : 11:58:29
|
| If there is data in ANALYSIS_TEMP, I want to exit the stored procedure. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-03 : 12:00:29
|
quote: Originally posted by carmitage If there is data in ANALYSIS_TEMP, I want to exit the stored procedure.
i think what you need to do is to have a bit field on your procedure/function and based on whether it has data in table or not, just return value as 1 or 0 |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-11-03 : 13:10:59
|
aww shucks! now i'm going to go dust myself with ash _______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.1 out! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-04 : 01:38:37
|
quote: Originally posted by visakh16 the statement itself is wrong it should be this i guessif (select count(*) from alm.dbo.ANALYSIS_TEMP) > 1 'Display a message'else'Display a different message'
More effecientlyif exists(select * from alm.dbo.ANALYSIS_TEMP) 'Display a message'else'Display a different message'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|