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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:10:21+00:00 2026-05-11T22:10:21+00:00

I recently accidently wrote a really ugly stored proc where I wished I had

  • 0

I recently accidently wrote a really ugly stored proc where I wished I had enums,

Eg.

CREATE PROCEDURE Proc_search_with_enum @user int, @account_category {enum}

I understand that SQL 2000 doesn’t have enums as a first class language construct, which coding conventions do you use to simulate enums or otherwise address the same issue?

Or am I’m I doomed to just using VARCHAR and IF @account_category=’cat1′?

EDIT: T-SQL and C# are the client languages.

EDIT: Thanks all! Lots of good advice, I wish I could accept several answers, I’ve voted everyone up-

Summary of answers

  • Lean on C#’s enum by using int. Good
    for C# client code, makes TSQL client
    code less readable.
  • Use Char/Varchar. Bad for C# client code
    (not good for localization), makes
    TSQL code more readable.
  • Use parameter checking code to restrict
    the parameter, or use a constraint on
    a table column or a foreign key if
    the parameter is going to be inserted
    into a table.
  • 1 1 Answer
  • 1 View
  • 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-11T22:10:21+00:00Added an answer on May 11, 2026 at 10:10 pm

    You could take a look at the answer to this question. As far as I know, enum types are not part of SQL Server.

    Anyhow, it’s better to use an integral (INT, TINYINT, …) type for your enums than a string type. Usually the enum types in your programming language of choice correspond better to integers than to strings.

    In C#, by default every enum value corresponds to an integer, starting from 0. You can even cast between them, so this is valid code:

    public enum MyEnum
    {
        FirstEnumValue = 0,
        SecondEnumValue = 1
    }
    
    ...
    
    // Assuming you have opened a SqlDataReader.
    MyEnum enumValue = (MyEnum) reader["account_category"];
    

    And LINQtoSQL also supports this. If you have an enum-typed property and your database column is an integer type, conversion is automatic.

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

Sidebar

Related Questions

I had a really huge problem recently which took me a lot of time
Recently I was able to create a tablet software for my Cerebral Palsy girl
I recently wrote a post: Weird Error in C++ Program: Removing Printout Breaks Program
Recently just upgraded to SQL Server 2008 R2 Express. When I attempt to create
Recently, we had released an app. Before we releasing, we tested it on Samsung
I have recently started a new job where they do most everything via Stored
Recently, I found that an array can be initialize as follows: private static int[]
We have recently started using git and had a nasty problem when someone committed
So I accidentally wrote a Haskell answer to a Scala question recently. Being rather
I recently wrote a quick-and-dirty proof-of-concept proxy server in C# as part of an

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.