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 |
|
stuckne1
Starting Member
22 Posts |
Posted - 2010-01-14 : 15:05:00
|
| Hi, i'm trying to check to see whether something exists or not before I allow the stored procedure to add the entry. ALTER PROCEDURE [dbo].[P_sp_UpdateCompletedModules] -- Add the parameters for the stored procedure here @ParkID int, @module_id intASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; var @counter as int SELECT * FROM tblCompleted join tblBPIModules on tblCompleted.module_id = tblBPIModules.id WHERE user_id = @ParkID AND module_id = @module_id IF @counter = 0 BEGIN INSERT INTO tblCompleted(user_id, module_id) VALUES(@ParkID, @module_id) ENDEND |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
|
|
stuckne1
Starting Member
22 Posts |
Posted - 2010-01-14 : 15:24:42
|
| I will read those articles. Thank you very much! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
DP978
Constraint Violating Yak Guru
269 Posts |
Posted - 2010-01-14 : 15:49:51
|
| Sorry tara, i would of informed the same, but in my example I removed counter altogether. But she is quite right, no var in sql. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|