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 8651069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:58:20+00:00 2026-06-12T13:58:20+00:00

I have created a stored procedure to retrieve some details based on the certain

  • 0

I have created a stored procedure to retrieve some details based on the certain values passed to a parameter. THis requires switching between the SQLs to be executed by stored procedure. Following is the code:

USE [DFS]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[DAFS]
@EmailID Nvarchar(128),
@clientID int,
@userType Varchar(50),
@Success numeric output, 
@msg varchar(100) output  

AS

BEGIN
    if @userType='Normal User'
        IF EXISTS (SELECT 1 FROM dbo.Allcdn 
                    WHERE EmailID = @EmailID AND ClientID = @clientID) 
            begin
                set @Success=0
                set @msg='Carry on ....'
            end
        else
            begin
                set @Success=6  
                set @msg='Not allowed ...' 
            END
        end
    else
        Begin
            IF EXISTS (SELECT 1 FROM dbo.Alcon 
                        WHERE EmailID = @EmailID AND ClientID = @clientID) 
                BEGIN
                    set @Success=0
                    set @msg='Carry on...' 
                END 
            END
        End
    end
END

The entire processing is based on the variable @userType. Not sure why the stored procedure is not compiling.

  • 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-12T13:58:21+00:00Added an answer on June 12, 2026 at 1:58 pm

    Formatting is your friend, just with a quick glance, it appears you have too many ENDs — See SQL Fiddle with working Demo:

    CREATE PROCEDURE [dbo].[DAFS]
      @EmailID Nvarchar(128),
      @clientID int,
      @userType Varchar(50),
      @Success numeric output, 
      @msg varchar(100) output  
    
    AS
    BEGIN
      if @userType='Normal User'
        IF EXISTS (SELECT 1 FROM dbo.Allcdn 
                    WHERE EmailID = @EmailID AND ClientID = @clientID) 
          begin
            set @Success=0
            set @msg='Carry on ....'
          end
        else
          begin
            set @Success=6  
            set @msg='Not allowed ...' 
          END
      else
        Begin
          IF EXISTS (SELECT 1 FROM dbo.Alcon 
                        WHERE EmailID = @EmailID AND ClientID = @clientID)
            BEGIN
              set @Success=0
              set @msg='Carry on...' 
            END 
        END
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just created a report in Report Manager using a Stored Procedure which
I have a dynamic SQL statement I've created in a stored procedure. I need
I have this stored procedure: CREATE OR REPLACE PROCEDURE LIQUIDACION_OBTENER ( p_Cuenta IN NUMBER,
I have this stored procedure for Oracle: create or replace procedure bns_saa_message_get() <--- PROBLEM
I have to improve some code where an Oracle stored procedure is called from
I have multiple tables . I have created one stored procedure where I am
Have a question about stored procedure: How to retrieve the variable's value from stored
I have this rather crazy idea to have a stored procedure facility in my
Let's assume, we create a stored procedure that is supposed to retrieve customer details
I have the following stored procedure to retrieve a new datetime: CREATE PROCEDURE [dbo].[GetTransactionTime]

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.