Avatar of Glen_D
Glen_D asked on

SP would accept a string as a parameter and return a boolean.

Need to accept a string and return a boolean value based on statement.  Thought I had this but missing something.

CREATE PROCEDURE usp_CheckUserName

@User_Login varchar(50)

as
Declare @E int

select @E = CASE when @User_Login in (select user_login from tbl_user)
          Then  = '1'
          Else  = '0'
End
Microsoft SQL Server 2008Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Glen_D

8/22/2022 - Mon
TimCottee

Hello Glen_D,

Create Procedure usp_CheckUserName
(
  @User_Login varchar(50)
)

As

Declare @E bit -- bit is the boolean equivalent in sql server

If Exists(Select user_login from tbl_user Where user_login = @user_login)
  Set @bit = 1
Else
  set @bit = 0

Select @bit As Result


Regards,

TimCottee
ASKER CERTIFIED SOLUTION
Aneesh

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Glen_D

Thanks....just had to change the variable name to @E....
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes