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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:19:03+00:00 2026-05-12T13:19:03+00:00

I have a Sales tax column in one of my SQL Table where Data

  • 0

I have a Sales tax column in one of my SQL Table where Data is stored.

I was wondering is it possible to place an constraint on the table itself for the Sales Tax

Column saying ” if > June 2008 tax is 2 % ” else “tax is 4 %”?

Should that come from stored procs related to that Table?

  • 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-12T13:19:04+00:00Added an answer on May 12, 2026 at 1:19 pm

    If you want to make sure that the column ‘tax’ is 2 or 4 depending on the month (e.g., month 9 = September), then you could do this:

    ALTER TABLE SomeTable 
       ADD CONSTRAINT CK_SalesTax
       CHECK ((MONTH(GETDATE()) = 9 AND SalesTax = 2) OR (MONTH(GETDATE()) != 9 AND SalesTax = 4))
    

    Obviously, vary for your conditions. e.g., to test for dates after June 2008, it’s a bit simpler.

    (GETDATE() >= '1 June 2008' AND SalesTax = 2)
    

    You should be able to build this into a CHECK constraint of using a similar mechanism as I’ve dropped in the first example.

    Note this only checks the value that put in to the table. It won’t auto-populate. As other people have noted, if you want auto-population, you need a trigger.

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

Sidebar

Related Questions

I have a table with sales per store as follows: SQL> select * from
I have one table that has sales records and another table that has additional
I have the following SQL table - Date StoreNo Sales 23/4 34 4323.00 23/4
I need a little help brainstorming on a query. I have a sales table
I have a table named with Sales having the following columns: Sales_ID|Product_Code|Zone|District|State|Distributor|Total_Sales Now i
How does one handle situation when you have sales orders and items tables, and
I have a Customer table --> CustomerNumber and CustomerName columns I have a Sales
I have created a function (see below) that calculates a 7.5% sales tax. Now
In a quick-and-dirty Perl script, I have a data structure like this: $tax_revenue{YEAR}{STATE}{GOVLEV}{TAX} =
Let's say I have a Sales table, that contains columns ProductID, Date, ... some

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.