473,408 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Conditional Constraints on table columns

6
Guys,

Does SQL Server allow for creating conditional constraints on the table columns?

My table is:

CREATE TABLE [X]
(

[UID] [int] IDENTITY (1, 1) NOT NULL ,
[A] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CS_AS NOT NULL ,
[b] [bit] NOT NULL ,


CONSTRAINT [PK_X] PRIMARY KEY CLUSTERED
(

[UID]

) ON [PRIMARY]

) ON [PRIMARY]

I want to add the following constraints:

CONSTRAINT [IX_UNIQUE1] UNIQUE NONCLUSTERED

(
A, B = 1

) ON [PRIMARY]

CONSTRAINT [IX_UNIQUE2] UNIQUE NONCLUSTERED

(
UPPER(A), B = 0

) ON [PRIMARY]



That is, if the table contains "Hello" in column A, then an insert of ("hello", 1) will be rejected, but ("hello", 0) will be inserted.

Any ideas?

Thanks a lot
Nov 28 '06 #1
0 1534

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Robin Tucker | last post by:
I'm considering adding domain integrity checks to some of my database table items. How does adding such constraints affect SQL Server performance? For example, I have a simple constraint that...
10
by: serge | last post by:
I am doing a little research on Google about this topic and I ran into this thread: ...
3
by: Andreas Fromm | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Please consider the following situation. CREATE TABLE test_table ( ~ id SERIAL PRIMARY_KEY, ~ tag BOOLEAN, ~ field1 INTEGER );
3
by: Chuck Reed | last post by:
I am working on a sales report where I show weekly sales by category for each of the 52 weeks in the year. Each record in my table/report has the 52 weeks of sales in it. I want to highlight to top...
0
by: Frnak McKenney | last post by:
One part of a customer project I'm working on involves what seem like fairly straightforward updates to a set of related tables. While I've developed software for a number of years (it only seems...
6
by: Emin | last post by:
Dear Experts, When I use a single table I can easily use constraints to enforce my business logic, but what do I do when I normalize a single table into multiple tables. For example, imagine...
5
by: yeoj13 | last post by:
Hello, I have a db2load script I'm using to populate a large table. Ideally, my target table is required to have "Not Null" constraints on a number of different columns. I've noticed a ...
1
by: Dan Holmes | last post by:
How do you connect the check constraints on the Table object with the columns in the table? I ended up doing this and it smells bad. foreach (Column cn in t.Columns) { foreach (Check ch in...
2
by: Kenneth Koenraadt | last post by:
Hi Wing, The utility Oracle offers for that is *check constraints*. For instance : ALTER TABLE Demerit ADD CONSTRAINT a1 CHECK (points between 1 and 6); ALTER TABLE Demerit ADD CONSTRAINT...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.