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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:00:28+00:00 2026-05-26T18:00:28+00:00

While using ‘ CASE ‘ I encountered with problem that I’D never heard. The

  • 0

While using ‘CASE‘ I encountered with problem that I’D never heard.
The problem is so: I’M using ‘CASE‘ statement in ‘SELECT‘ clause as a field. When calling columns with int data type, it’s successful; However, When calling a varchar or datetime, it’s unsuccessful.
İn the error result, it’s said me to have marked the temporary field, including ‘CASE‘ statement, as int, But not so. Please help…

The ‘STORED PROCEDURE’ Content

CREATE PROC spRegistry_PersonsGetField
@ID int,
@Field varchar(100)
AS
SELECT CASE @Field 
WHEN 'Name' THEN Name
WHEN 'Surname' THEN Surname
WHEN 'Username' THEN Username
WHEN 'Password' THEN Password
WHEN 'Status' THEN dbo.fnStatus(Status)
WHEN 'EMail' THEN EMail
WHEN 'Tel' THEN dbo.fnIsEmpty(Tel)
WHEN 'Address' THEN dbo.fnIsEmpty(Address)
WHEN 'City' THEN dbo.fnIsEmpty(City)
WHEN 'BirthDate' THEN dbo.fnDate(BirthDate)
WHEN 'Gender' THEN dbo.fnGender(Gender)
WHEN 'Lang' THEN Lang
ELSE NULL
END
AS [Alan] varchar(200)
FROM Registry_Persons
WHERE ID = @ID

My Query

EXEC spRegistry_PersonsGetField 1, ‘BirthDate’

The Error Message

Conversion failed when converting the varchar value ’04/11/2011′ to data type int.

  • 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-26T18:00:28+00:00Added an answer on May 26, 2026 at 6:00 pm

    T-SQL’s Precedence rules apply when a CASE is evaluated in order to work out what the single returned datatype is to be. Since int has a higher precedence than varchar an implicit conversion to int is attempted & subsequently fails.

    To fix this, convert your int or datetime expressions to varchar.

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

Sidebar

Related Questions

While using @font-face I am facing a problem that is when I am going
While using regex to help solve a problem in the Python Challenge , I
While using fixed width select tag , there is one bug in IE. When
While using Java's switch case, it excepts only char and int, but I want
While using session in Rails, what are the things that I have to be
While using inner join on Pro*C I am getting the below error: PCC-S-02201, Encountered
i have a problem while using jquery context menu and update panels. i am
While using the Paypal iPhone SDK that integrates a mobile payment option on the
While using method Arrays.deepToString(Object [] a) I am facing this problem which I can
While using jCart I noticed that it did not work on the iPhone. After

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.