|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
scripting bug when unique nonclustered index contains included colCREATE UNIQUE NONCLUSTERED INDEX [IX_ProductReview_Test] ON [Production].[ProductReview] ([ProductID] ASC, [ReviewerName] ASC) INCLUDE ( [ProductReviewID]) WITH (PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY] Script the database by right-clicking AdventureWorks, choose Tasks, Generate Scripts, turn off IF NOT EXISTS, and turn on Indexes. Select Tables and Select All. The script generated for the index is as follows. CREATE UNIQUE NONCLUSTERED INDEX [IX_ProductReview_Test] ON [Production].[ProductReview] ([ProductReviewID] ASC, [ReviewerName] ASC) INCLUDE ( [ProductID]) WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] The ProductReviewID and ProductID fields are reversed. The problem does not occur if the index is created without the UNIQUE option. -- Brian C. Berg Berg Information Technology, Inc. Brian C. Berg (BrianCB***@discussions.microsoft.com) writes:
Show quote > To reproduce the problem, run the following script in AdventureWorks. And neither does it occur if you script only that table. Not really > > CREATE UNIQUE NONCLUSTERED INDEX [IX_ProductReview_Test] ON > [Production].[ProductReview] ([ProductID] ASC, [ReviewerName] ASC) > INCLUDE ( > [ProductReviewID]) WITH (PAD_INDEX = OFF, SORT_IN_TEMPDB = OFF, > DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY] > > Script the database by right-clicking AdventureWorks, choose Tasks, > Generate Scripts, turn off IF NOT EXISTS, and turn on Indexes. Select > Tables and Select All. > > The script generated for the index is as follows. > > CREATE UNIQUE NONCLUSTERED INDEX [IX_ProductReview_Test] ON > [Production].[ProductReview] ([ProductReviewID] ASC, [ReviewerName] ASC) > INCLUDE ( [ProductID]) WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON > [PRIMARY] > > The ProductReviewID and ProductID fields are reversed. The problem does > not occur if the index is created without the UNIQUE option. the sort of bug that serves to give you confidence in the tool... Anyway, if you have not filed this bug on https://connect.microsoft.com/SQLServer/Feedback, you sholud so. -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
|||||||||||||||||||||||