March 26, 2019 at 5:01 pm
If you don't specify Unique, then by default a non-unique index is created. But suppose I wanted to explicitly create a non-unique index (just to understand how SQL works).
What is wrong with this code. With or without the hyphen, I still get an error.
CREATE NON-UNIQUE NONCLUSTERED INDEX ix_testIndex
ON Roster(firstName);
March 26, 2019 at 5:34 pm
michael.leach2015 - Tuesday, March 26, 2019 5:01 PMIf you don't specify Unique, then by default a non-unique index is created. But suppose I wanted to explicitly create a non-unique index (just to understand how SQL works).What is wrong with this code. With or without the hyphen, I still get an error.
CREATE NON-UNIQUE NONCLUSTERED INDEX ix_testIndex
ON Roster(firstName);
You can specify unique or you can leave it off. Leave it off and you have defined a non-unique index. So in your example, it's just: CREATE NONCLUSTERED INDEX ix_testIndex
ON Roster(firstName);
The documentation has the first line of the statement as:
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
You can find the syntax in this documentation:
CREATE INDEX (Transact-SQL)
Sue
March 26, 2019 at 5:34 pm
michael.leach2015 - Tuesday, March 26, 2019 5:01 PMIf you don't specify Unique, then by default a non-unique index is created. But suppose I wanted to explicitly create a non-unique index (just to understand how SQL works).What is wrong with this code. With or without the hyphen, I still get an error.
CREATE NON-UNIQUE NONCLUSTERED INDEX ix_testIndex
ON Roster(firstName);
Google for "CREATE INDEX" and see that NON-UNIQUE is NOT valid and neither is NONUNIQUE.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 28, 2019 at 8:15 am
Jeff Moden? Are you the same person with the awesome splitter function?? I used your version and made a few minor tweaks to have it do what I needed it to do...its pretty awesome! Just wanetd to say thanks if that was you and let you know it was much appreciated!
March 28, 2019 at 9:18 am
Jeff is indeed the MASTER OF THE TALLY TABLE.... and many other things besides.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 28, 2019 at 10:55 am
I'm humbled. Thank you for the kind words and, as Dixie said, yes... that's me. :blush: I'll also say that it's not just me. DelimitedSplit8K is one of the finest examples in the world of community effort. As the revisions say in the header, a lot of great people a hand in it to make it what is is today.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy