question

craazycat avatar image
craazycat asked

What's the syntax for multiple nonclustered indexes?

I am creating a temp table and need individual indexes on a number of columns. Here is what I have so far, but the syntax is wrong. What do I put between each create? CREATE NONCLUSTERED INDEX [linkKey] ON #tmpInvent ([ItemNo] ASC) CREATE NONCLUSTERED INDEX ON #tmpInvent ([WH_ID] asc) CREATE NONCLUSTERED INDEX ON #tmpInvent ([Date] asc)
indexessyntaxnonclustered-index
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JohnM avatar image
JohnM answered
It looks like the subsequent CREATE's are missing the index name. CREATE NONCLUSTERED INDEX IX_Indexname ON #tmplnvent (Date)
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

craazycat avatar image craazycat commented ·
Oh dear! I copied this from another script that only used the first line and didn't realize that was the name. I was wondering what a [linkKey] was! Yikes - I have a lot to learn. Thank you!
0 Likes 0 ·
JohnM avatar image JohnM commented ·
Your very welcome! Hopefully that solved your issue! If so, please make sure to mark your question as answered so that others know the issue has been solved. Thanks!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.