Re: create table -
11-10-2009
, 08:55 PM
If I understand correctly you want to include the creation of the nonclustered index in the CREATE TABLE statement. The
CREATE TABLE statement only allows you to specify column or table constraints (PRIMARY KEY or UNIQUE) and since they are
enforced by an index you can additionally specify CLUSTERED or NONCLUSTERED. But you cannot explicitly create an index.
If the two columns in the index that you want to create can serve as unique combination, then an UNIQUE constraint can
be used to create the index indirectly. Here is example:
CREATE TABLE AppUser_Perm (
id INT NOT NULL CONSTRAINT pk_appuser_perm PRIMARY KEY,
appuser_perm INT NOT NULL,
raa_id INT NOT NULL,
CONSTRAINT un_appuser_perm
UNIQUE (appuser_perm, raa_id));
--
Plamen Ratchev
http://www.SQLStudio.com |