March 27, 2019 at 9:32 pm
Comments posted to this topic are about the item Speedy Table Variables
March 27, 2019 at 11:20 pm
The correct answer should be "It Depends" on which version of SQL Server you have. IIRC, this is a 2019 feature and it hasn't yet been RTM'd yet, has it?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 27, 2019 at 11:35 pm
Jeff Moden - Wednesday, March 27, 2019 11:20 PMThe correct answer should be "It Depends" on which version of SQL Server you have. IIRC, this is a 2019 feature and it hasn't yet been RTM'd yet, has it?
Nice question, thanks Steve
Actually, Jeff, this has been possible since SQL 2014
Starting with SQL Server 2014 (12.x), new syntax was introduced which allows you to create certain index types inline with the table definition. Using this new syntax, you can create indexes on table variables as part of the table definition
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
March 28, 2019 at 12:07 am
Good question, thanks Steve.
...
March 28, 2019 at 5:09 am
This syntax is not valid for SQL SERVER 2012.
Until this version, constraint with explicit name, can't be created for table variable.
However , same can be achieved by defining primary (for unique clustered index) and unique (for unique non clustered index) key.
March 28, 2019 at 5:21 am
amit-412380 - Thursday, March 28, 2019 5:09 AMThis syntax is not valid for SQL SERVER 2012.
Until this version, constraint with explicit name, can't be created for table variable.
However , same can be achieved by defining primary (for unique clustered index) and unique (for unique non clustered index) key.
the functionality was introduced with SQL 2014...
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
March 28, 2019 at 6:46 am
Ran my test in 2008 R2:
Be still, and know that I am God - Psalm 46:10
March 28, 2019 at 7:12 am
As a few have pointed out this may or may not work the same depending on the version. It has also long been the standard for the QOTD that unless otherwise stated you should assume the most recent released version.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 28, 2019 at 8:05 am
Stewart "Arturius" Campbell - Wednesday, March 27, 2019 11:35 PMJeff Moden - Wednesday, March 27, 2019 11:20 PMThe correct answer should be "It Depends" on which version of SQL Server you have. IIRC, this is a 2019 feature and it hasn't yet been RTM'd yet, has it?Nice question, thanks Steve
Actually, Jeff, this has been possible since SQL 2014Starting with SQL Server 2014 (12.x), new syntax was introduced which allows you to create certain index types inline with the table definition. Using this new syntax, you can create indexes on table variables as part of the table definition
Ah... I stand corrected, Stewart. Thanks. I guess a part of my bad memory here is that I try to avoid Table Variables like the plague unless absolutely nothing else will do.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 28, 2019 at 8:31 am
Jeff Moden - Thursday, March 28, 2019 8:05 AMStewart "Arturius" Campbell - Wednesday, March 27, 2019 11:35 PMJeff Moden - Wednesday, March 27, 2019 11:20 PMThe correct answer should be "It Depends" on which version of SQL Server you have. IIRC, this is a 2019 feature and it hasn't yet been RTM'd yet, has it?Nice question, thanks Steve
Actually, Jeff, this has been possible since SQL 2014Starting with SQL Server 2014 (12.x), new syntax was introduced which allows you to create certain index types inline with the table definition. Using this new syntax, you can create indexes on table variables as part of the table definition
Ah... I stand corrected, Stewart. Thanks. I guess a part of my bad memory here is that I try to avoid Table Variables like the plague unless absolutely nothing else will do.
Same here. They are great for answering forum questions but in real code I have used them, at least I think, exactly never.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 28, 2019 at 10:09 am
Sean Lange - Thursday, March 28, 2019 8:31 AMJeff Moden - Thursday, March 28, 2019 8:05 AMStewart "Arturius" Campbell - Wednesday, March 27, 2019 11:35 PMJeff Moden - Wednesday, March 27, 2019 11:20 PMThe correct answer should be "It Depends" on which version of SQL Server you have. IIRC, this is a 2019 feature and it hasn't yet been RTM'd yet, has it?Nice question, thanks Steve
Actually, Jeff, this has been possible since SQL 2014Starting with SQL Server 2014 (12.x), new syntax was introduced which allows you to create certain index types inline with the table definition. Using this new syntax, you can create indexes on table variables as part of the table definition
Ah... I stand corrected, Stewart. Thanks. I guess a part of my bad memory here is that I try to avoid Table Variables like the plague unless absolutely nothing else will do.
Same here. They are great for answering forum questions but in real code I have used them, at least I think, exactly never.
One of their uses is where you need to capture information that would otherwise be lost when doing a rollback in a transaction.
March 28, 2019 at 10:41 am
Lynn Pettis - Thursday, March 28, 2019 10:09 AMSean Lange - Thursday, March 28, 2019 8:31 AMJeff Moden - Thursday, March 28, 2019 8:05 AMStewart "Arturius" Campbell - Wednesday, March 27, 2019 11:35 PMJeff Moden - Wednesday, March 27, 2019 11:20 PMThe correct answer should be "It Depends" on which version of SQL Server you have. IIRC, this is a 2019 feature and it hasn't yet been RTM'd yet, has it?Nice question, thanks Steve
Actually, Jeff, this has been possible since SQL 2014Starting with SQL Server 2014 (12.x), new syntax was introduced which allows you to create certain index types inline with the table definition. Using this new syntax, you can create indexes on table variables as part of the table definition
Ah... I stand corrected, Stewart. Thanks. I guess a part of my bad memory here is that I try to avoid Table Variables like the plague unless absolutely nothing else will do.
Same here. They are great for answering forum questions but in real code I have used them, at least I think, exactly never.
One of their uses is where you need to capture information that would otherwise be lost when doing a rollback in a transaction.
THAT is the the only time that I've used them and that was precisely once and that was more than a decade ago.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply