Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 563537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:40:15+00:00 2026-05-13T12:40:15+00:00

I have a store procedure like this : ALTER PROCEDURE [dbo].[CheckUser&Pass] ( @Username nchar(15),

  • 0

I have a store procedure like this :

ALTER PROCEDURE [dbo].[CheckUser&Pass]
(
    @Username nchar(15),
    @Password nchar(15)
)
AS
    SET NOCOUNT ON;
SELECT        Username, Pass, Code_Person
FROM            Login
WHERE        (Username = @Username) AND (Pass = @Password)

And Execution :

DECLARE @return_value int

EXEC    @return_value = [dbo].[CheckUser&Pass]
        @Username = N'admin',
        @Password = N'1234'

SELECT  'Return Value' = @return_value

GO

I Want to know how I can set @return_Value to 1 when the username is admin and password is 1234.

but it doesn’t work properly, is that possible ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:40:16+00:00Added an answer on May 13, 2026 at 12:40 pm

    To set the return value within a stored procedure, you need to use the RETURN statement

    e.g.

    IF (@@ROWCOUNT > 0 AND @Username = 'admin' and password='1234')
        RETURN 1
    ELSE
        RETURN 0
    

    Please note, I’ve given exactly what you’ve asked for just to demonstrate use of the RETURN statement. There’s a few concerns I have that should be pointed out:

    1. Looks like you’re storing the password in plain text, which if is the case, is a bad idea
    2. This hardcoded condition for admin username and password combination is horrible. One better solution is to have an “IsAdmin” flag in the db – if the supplied username/password is valid, then return 1 if the flag indicates the account is an admin.
    3. Use of nchar – all usernames and passwords will be padded out to 15 characters. You should consider nvarchar instead.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic query which reads like this Alter PROCEDURE dbo.mySP -- Add
Let's say I have a simple stored procedure that looks like this (note: this
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
I have stored procedure: ALTER PROCEDURE [dbo].[k_ShoppingCart_DELETE] @cartGUID nvarchar AS DELETE FROM [dbo].[k_ShoppingCart] WHERE
I would like to do the following. Basically have a stored procedure call another
Say I have this great query in my stored procedure. Select * from Temp
I have this stored procedure, that reads data from xml and make some inserts
I have a stored procedure that is called by another stored procedure ALTER PROCEDURE
I have a strange, sporadic issue. I have stored procedure that returns back 5
I have a stored procedure in SQL 2005. The Stored Procedure is actually creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.