• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

If Exists

How can I use multiple IF exists statemetns in stored procedure? please provide samples or good links.

ayha
0
ayha1999
Asked:
ayha1999
2 Solutions
 
jason987Commented:
CREATE PROCEDURE spAddNewUser
@UserName varchar (50),
@Password varchar (10),
@NewUserID int = null OUTPUT
AS
IF EXISTS (SELECT * FROM Security WHERE UserName = @UserName)
select 'exists!'
ELSE
select 'not exists!'
0
 
Alpesh PatelAssistant ConsultantCommented:
IF EXISTS (SELECT * FROM Security WHERE UserName = @UserName)
select 'exists!'
else IF EXISTS (SELECT * FROM Table2 WHERE UserName = @UserName)
select 'exists2!'
ELSE
select 'not exists!'
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now