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
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of Aneesh
Aneesh
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Glen_D
Glen_D

ASKER

Thanks....just had to change the variable name to @E....
Microsoft SQL Server 2005
Microsoft SQL Server 2005

Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.

72K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo