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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:32:02+00:00 2026-06-01T02:32:02+00:00

When I try to run update a credit card type by passing in the

  • 0

When I try to run update a credit card type by passing in the @ID and @Name I get an error that says:

Msg 2786, Level 16, State 1, Procedure sp_SaveCreditCardType, Line 29
The data type of substitution parameter 1 does not match the expected type of the format specification.

The problem is with my piece of code that checks for the existence of the id in the CreditCardTypes table using this statement:

-- make sure the ID is a valid number
        IF NOT EXISTS (SELECT * FROM CreditCardTypes WHERE ID = @ID)
            BEGIN
                RAISERROR('The Credit Card ID ''%s'' does not exist. Update Failed.', 15, 1, @ID)
                RETURN -100
            END

Does anyone have any idea why this may be giving me an error? I have seen many examples of using the the if exists() in this way, but for some reason it’s giving me an error.

Here is the entire proc.

CREATE PROCEDURE dbo.sp_SaveCreditCardType 
(
@ID int = null, 
@Name varchar(50),
@Description varchar(150) = null 
)
AS

DECLARE 
@Err INT

BEGIN 
SET NOCOUNT ON 

-- check to make sure a Name was passed in
IF @Name IS NULL
    BEGIN
        RAISERROR('A Name was not specified. Execution aborted.', 15, 1, @Name)
        RETURN -100
    END

-- check to see if an ID is passed
IF @ID IS NOT NULL AND @ID <> 0
    BEGIN
        -- make sure the ID is a valid number
        IF NOT EXISTS (SELECT * FROM CreditCardTypes WHERE ID = @ID)
            BEGIN
                RAISERROR('The Credit Card ID ''%s'' does not exist. Update Failed.', 15, 1, @ID)
                RETURN -100
            END

        -- update an existing credit card type
        UPDATE CreditCardTypes 
            SET Name = @Name, 
                [Description] = @Description
            WHERE ID = @ID
        SET @Err = @@ERROR
            IF @Err <> 0 GOTO ErrorHandler
    END
ELSE
    BEGIN
        -- first check to make sure the credit card type doesn't already exist
        IF NOT EXISTS (SELECT * FROM CreditCardTypes WHERE Name = @Name)
            BEGIN
                -- insert a new credit card type
                INSERT INTO CreditCardTypes (Name, [Description])
                VALUES (@Name, @Description)

                SET @Err = @@ERROR
                    IF @Err <> 0 GOTO ErrorHandler
            END
        ELSE
            RAISERROR('The Credit Card Type ''%s'' already exists. Insert failed.', 15, 1, @Name)
            RETURN -100
    END

SET @Err = @@ERROR
    IF @Err <> 0 GOTO ErrorHandler
RETURN 0

ErrorHandler:
    RAISERROR('An error occured while saving the credit card type ''%s''', 16, 1, @Name) WITH LOG
    RETURN -100
END
GO
  • 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-01T02:32:03+00:00Added an answer on June 1, 2026 at 2:32 am

    Change:

    RAISERROR('The Credit Card ID ''%s'' does not exist. Update Failed.', 15, 1, @ID)
    

    To:

    RAISERROR('The Credit Card ID ''%d'' does not exist. Update Failed.', 15, 1, @ID)
    

    %s is used for substituting strings… but %d is the substitution parameter for ints.

    RAISERROR in MSDN

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to run the update manager in Eclipse, I get the error
When I try to run any update query in Access 2007, I get the
I am getting this error when I try to run a update query on
Whenever i try to run sqlmetal, i get this: 'sqlmetal' is not recognized as
I keep getting an SWTException that says Invalid Thread Access when I try and
When I try to run the following C++ program: UPDATE (Updated code since the
Hi all i am getting deployment error when i try to run my app
For some reason, when I try to run this code, all I get is
I have ruby and gems installed, but when I try to run the update
I need to update a couchdb document, when i try and run the command

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.