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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:41:50+00:00 2026-05-31T19:41:50+00:00

I have a table named myTable on SQL Server 2008 R2 Express. I would

  • 0

I have a table named myTable on SQL Server 2008 R2 Express.

I would like to have a (marital) Status column with the only explicit values: ‘Single’, ‘Married’, ‘Divorced’, ‘Widower’.
The default should be ‘Married’.

Is there a way to limit the field to the above values ON THE SQL Server without additional tables?

  • 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-31T19:41:51+00:00Added an answer on May 31, 2026 at 7:41 pm

    You can do that with a CHECK() constraint.

    create table whatever (
    ...
      Status varchar(12) not null default 'Married' 
        check (Status in ('Single', 'Married', 'Divorced', 'Widower')),
    ...
    );
    

    The problem with using a CHECK constraint like this is that it’s harder for the user interface to present a list of valid choices to the user for selection. If these four were stored in a table of marital statuses, you could just select status from marital_statuses order by status;. If they were stored in a table, you could still use ‘Married’ as the default.

    If I were going to store these in a table, it might look like this.

    create table marital_statuses (
      status_code char(1) primary key,
      status_text varchar(12) not null unique
    );
    
    insert into marital_statuses values
    ('s', 'Single'),
    ('m', 'Married'),
    ('d', 'Divorced'),
    ('w', 'Widower');
    

    Using human-readable codes means you usually won’t need an additional join. (If you use ID numbers, you always need an additional join.) If I did that, I’d use a foreign key in the “whatever” table, and change the default to ‘m’.

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

Sidebar

Related Questions

I have a simple database table (SQL Server 2008 R2 Express), which has a
I have my own database (SQL Server 2008 RQ) and i have a table
I have a SQL Server 2008 database with the following information in a table:
I have a table named visiting that looks like this: id | visitor_id |
DBMS: MS Sql Server 2005, Standard I'd like to make a table constraint to
I am new to SQL and SQL Server 2008 R2. I have found a
Database Name = MyDB Table Name = MyTable Column Name = ColumnSurname Using SQL
I have SQL Server data base where i am storing city Name. Like Delhi;
I have a single row of data in a SQL Server table that I'm
I have to use MS SQL Server 2008 to store data of PHP CAKE

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.