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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2002-08-29 : 15:41:27
|
| I need to modify this SP to check one more thing. I need to check if this statement:SELECT count(userID) as total FROM tblhotList WHERE userid=@userIDis > 50If its greater I would like to exit the SP, as I do with the IF EXISTS clause. If it is not greater I want to proceed with the insert.What is the best way to implement this??CREATE PROCEDURE [insert_HotList] ( @UserID [int], @HotUserID [int], @Sort [tinyint] --COULD SET OUTPUT PARAMETER TO RETURN WHAT HAPPENED )AS SET NOCOUNT ONIF Exists (SELECT userID FROM tbl_HotList WHERE userID = @UserID AND HotUserID = @HotUserID)BEGIN --SET @UserID = 0 ReturnENDINSERT INTO [tbl_HotList] ( [UserID], [HotUserID], [Sort]) VALUES ( @UserID, @HotUserID, @Sort)GO |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-08-29 : 19:53:39
|
| How aboutIF (SELECT count(userID) as total FROM tblhotList WHERE userid=@userID) > 50 BEGIN... |
 |
|
|
|
|
|