September 22, 2007 at 2:37 pm
I have a stored proc that I want to prevent the insert to happen if the UserID and InvitedUserID are the same
ALTER PROCEDURE [dbo].[cs_njection_invitation_accepted]
@user-id int,
@SettingsID
int,
@InvitedUserID
int
AS
insert
into cs_njection_invite_points (UserID, SettingsID, InvitedUserID)
values
( @user-id, @SettingsID, @InvitedUserID)
Any ideas?
September 22, 2007 at 6:11 pm
it's easier than you thought.
several ways.
add a constraint to the table where UserID <> @InvitedUserid.
Use the If example below.
ALTER
PROCEDURE [dbo].[cs_njection_invitation_accepted]@user-id int,
@SettingsID
int,
@InvitedUserID
int
AS
IF @user-id <> @InvitedUserID
begin
insert
into cs_njection_invite_points (UserID, SettingsID, InvitedUserID)
values
( @user-id, @SettingsID, @InvitedUserID)
end
Lowell
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply