August 11, 2014 at 10:51 am
sektor81 (8/11/2014)
I wonder whether there's documentation about inline syntax for indexes for SQL Server 2014? I couldn't find it here.
CREATE TABLE Consumer
(
Account nvarchar(20) null,
Consumption float null,
INDEX IX_Consumer_Account NONCLISTURED (Account)
);
The only indexes that can be created during table creation are those that will be created by unique constraints. For example, PK's.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 11, 2014 at 12:22 pm
You're looking on the wrong page, the page you linked to is for Azure databases, where I assume this feature doesn't exist. If you look at the CREATE TABLE page for SQL Server 2014 (the non-Azure version), the inline syntax is listed.
http://msdn.microsoft.com/en-us/library/ms174979%28v=sql.120%29.aspx
CREATE TABLE
[ database_name . [ schema_name ] . | schema_name . ] table_name
[ AS FileTable ]
( { <column_definition> | <computed_column_definition>
| <column_set_definition> | [ <table_constraint> ]
| [ <table_index> ] [ ,...n ] } )
[ ON { partition_scheme_name ( partition_column_name ) | filegroup
| "default" } ]
[ { TEXTIMAGE_ON { filegroup | "default" } ]
[ FILESTREAM_ON { partition_scheme_name | filegroup
| "default" } ]
[ WITH ( <table_option> [ ,...n ] ) ]
[ ; ]
< table_index > ::=
INDEX index_name [ CLUSTERED | NONCLUSTERED ] (column [ ASC | DESC ] [ ,... n ] )
[ WITH ( <index_option> [ ,... n ] ) ]
[ ON { partition_scheme_name (column_name )
| filegroup_name
| default
}
]
[ FILESTREAM_ON { filestream_filegroup_name | partition_scheme_name | "NULL" } ]
}
Main use I think for this will be table variables where you no longer have to jump through hoops to get non-unique indexes.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 11, 2014 at 12:56 pm
Now that would be nice in "regular" T-SQL. Thanks for jumping in, Gail.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 11, 2014 at 1:00 pm
Jeff Moden (8/11/2014)
Now that would be nice in "regular" T-SQL.
Err.. It is in regular T-SQL, from SQL 2014 onwards.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 11, 2014 at 4:43 pm
GilaMonster (8/11/2014)
Jeff Moden (8/11/2014)
Now that would be nice in "regular" T-SQL.Err.. It is in regular T-SQL, from SQL 2014 onwards.
I'm so far behind that I'll need to be twins to catch-up. Most of the folks that I've been working with are still working with 2005 and I haven't given a thought to catching up to 2014, yet. Seems like I can't convince them to upgrade, either. Thanks for the info.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 11, 2014 at 11:18 pm
Gila, thanks a lot! This is very convenient syntax. 🙂
August 12, 2014 at 1:43 pm
On that note, I do wish that MS had devoted dev time to something more important instead of this "feature".
--Jeff Moden
Change is inevitable... Change for the better is not.
August 12, 2014 at 2:29 pm
The inline syntax is needed for hekaton tables because they're like table vars in that once created they cannot be changed. The fact that it works on normal tables as well is a bonus (probably would have been harder to develop it to only work on hekaton tables than all tables, since the create table syntax is very similar between the two)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 15, 2014 at 6:42 pm
GilaMonster (8/12/2014)
The inline syntax is needed for hekaton tables because they're like table vars in that once created they cannot be changed. The fact that it works on normal tables as well is a bonus (probably would have been harder to develop it to only work on hekaton tables than all tables, since the create table syntax is very similar between the two)
Thanks a lot, Gail. I appreciate the info especially as to the "why".
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply