sql server 2014 - Transact-SQL Enhancements - Inline specification of CLUSTERED and NONCLUSTERED

Hi experts,
I perfectly understand the difference between CLUSTERED and NONCLUSTERED indexes.

But, I do not understand what new: Inline specification of CLUSTERED and NONCLUSTERED

this is explanation:
Inline specification of CLUSTERED and NONCLUSTERED indexes is now allowed for disk-based tables. Creating a table with inline indexes is equivalent to issuing a create table followed by corresponding CREATE INDEX statements. Included columns and filter conditions are not supported with inline indexes.

You can explain with T-SQL code?
enrique_aeoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DBAduck - Ben MillerPrincipal ConsultantCommented:
Here is what it means. You can now specify inline with the CREATE TABLE statement the creation of indexes.  If I am creating a table with 1 column or 2 I can use this type of syntax.

-- this one creates a 1 column table with a NONCLUSTERED index called ix_1 on column c1
CREATE TABLE t1 ( c1 int, INDEX ix_1 NONCLUSTERED (c1)) 
CREATE TABLE t2( c1 int INDEX ix_1 NONCLUSTERED (c1)) 
-- this one will create an index on c2 that is NONCLUSTERED as you can see without a comma after c2 and no (column) at the end of the NONCLUSTERED statement.
CREATE TABLE t3( c1 int, c2 int INDEX ix_1 NONCLUSTERED) 
CREATE TABLE t4( c1 int, c2 int, INDEX ix_1 NONCLUSTERED (c1,c2))

Open in new window


Does that help?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
enrique_aeoAuthor Commented:
Have any advantage or saving only lines of code?
DBAduck - Ben MillerPrincipal ConsultantCommented:
It is more about syntax and inline code than it is about differences.  It creates the same indexes as if you used CREATE INDEX, but you don't have to have additional statements outside the CREATE table statement.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.