I have this CREATE TABLE statement:
[CODE=mysql]CREATE TABLE howto (
id INT IDENTITY(1,1) PRIMARY KEY,
title VARCHAR(100) UNIQUE NOT NULL,
url VARCHAR(20) UNIQUE NOT NULL,
order_on_homepa ge SMALLINT UNIQUE, --just put an order on this and if it's not null, then its on the homepage
CONSTRAINT CK_HOWTO_URL CHECK(url != ''),
CONSTRAINT CK_HOWTO_TITLE CHECK(title != '')
);
GO[/CODE]
I want order_on_homepa ge col to either have a SMALLINT value or a NULL value. However, if there is a SMALLINT value entered, I want those to be unique. In other words, I want to be able to add multiple NULL values in this col, but NOT multiple SMALLINT values. Any suggestions? A check? Thanks!
[CODE=mysql]CREATE TABLE howto (
id INT IDENTITY(1,1) PRIMARY KEY,
title VARCHAR(100) UNIQUE NOT NULL,
url VARCHAR(20) UNIQUE NOT NULL,
order_on_homepa ge SMALLINT UNIQUE, --just put an order on this and if it's not null, then its on the homepage
CONSTRAINT CK_HOWTO_URL CHECK(url != ''),
CONSTRAINT CK_HOWTO_TITLE CHECK(title != '')
);
GO[/CODE]
I want order_on_homepa ge col to either have a SMALLINT value or a NULL value. However, if there is a SMALLINT value entered, I want those to be unique. In other words, I want to be able to add multiple NULL values in this col, but NOT multiple SMALLINT values. Any suggestions? A check? Thanks!
Comment