PDA

View Full Version : MsSQL INDEXing a column


Coyote6
12-10-2009, 12:24 AM
Can someone please tell me the MsSQL equivalent of this MySQL statement:

CREATE TABLE `test` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(5),
`foreign_key` INT UNSIGNED NOT NULL DEFAULT '0',
UNIQUE INDEX (`name`),
INDEX (`foreign_key`)
);


I'm having a problem with the INDEX part. Here is what I have:

CREATE TABLE test (
id INT NOT NULL IDENTITY PRIMARY KEY,
name VARCHAR(5),
foreign_key INT NOT NULL DEFAULT '0',
UNIQUE (name),
INDEX (foreign_key)
);


Thanks.