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

  • SEARCH
  • Home
  • 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 8759017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:41:42+00:00 2026-06-13T14:41:42+00:00

I want to return a varchar(max) from a stored procedure in SQL Server 2008.

  • 0

I want to return a varchar(max) from a stored procedure in SQL Server 2008.

So I tried:

alter proc SpSignup(
    @username varchar(max),
    @email varchar(max),
    @password varchar(max),
    @warning varchar(max) output)
as
   if exists(select email from [login] where email=@email)
      return 'email already exists';

   insert into [login](username, email, password) 
   values(@username, @email, @password)

I want to return a varchar value ('email already exists') if the email exists in the table, and don’t want to give any @warning as parameter.

But it shows that @warning para is not supplying after exec this proc

Msg 201, Level 16, State 4, Procedure SpSignup, Line 0
Procedure or function ‘SpSignup’ expects parameter ‘@warning’, which was not supplied.

and also it doesn’t shows the output ('email already exists')

  • 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-06-13T14:41:44+00:00Added an answer on June 13, 2026 at 2:41 pm

    you forgot to supply parameter @username into your procedure

    declare @warning varchar(max)
    
    exec SpSignup
        @username = 'Bill', 
        @email = 'Bill@gmail.com',
        @password = '12345',
        @warning = @warning output
    
    select @warning
    

    UPDATE: It’s not possible to return varchar variable from procedure, you can pass it as output parameter or you can just code select 'email already exists' or print 'email already exists'

    alter proc SpSignup
    (
        @username varchar(max),
        @email varchar(max),
        @password varchar(max)
    )
    as
    begin
        if exists(select email from [login] where email=@email)
        begin
            select 'email already exists'
            print 'email already exists'
            return
        end
    
        insert into [login](username, email, password) values(@username, @email, @password)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help to return the 'xmlstring' (varchar(MAX)) from a Stored Procedure. It works
I want to write a t-sql stored procedure (aka sproc) which selects 3 columns
I want to return a private field from a remoted object but i get
I want to return a set of values from function till the point they
I have a data-source connected to a stored proc that will return the one
I have sql query in which i want return rows with distinct value order
i am having a SQL Procedure that always returns PRINT Command and i want
In SQL Server 2005 If I want to find the right-most one character of
I'm using SQL Server 2005, and want a user defined function to implement the
I have a Scalar-valued function in my DB: ALTER FUNCTION [dbo].[fx_fooFunct] (@MyParam varchar(max)) RETURNS

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.