SQL 2008 R2 Standard - Index View Support - sql-server

Many years ago (almost ten) I thought Index View is more like an enterprise edition (SQL 2000) only feature but I was wrong and Index view were indtroducted in SQL 2000 to satifsy competivive product's support for materialize view.
However, You can still create index view and physically materialize that view in all the edition of SQL 2000/2005 and query will use that index on a view if you specify NOEXPAND query hint (which is not needed in enterprise/developer editon)
Here is the white paper on Index View (that confirm what I said earlier)
http://msdn.microsoft.com/en-us/library/dd171921.aspx
However, it appears to me that starting with SQL 2008/R2 index view indeed is an enterprise edition feature.
I did compare feature by different edition
http://msdn.microsoft.com/en-us/library/cc645993.aspx
so in SQL 2008 R2 Standard edition you are able to create index view but looks like NOEXPAND hint will not work so it is almost useless...
Is it possible to create index view and use that index (instead of index on base table) in SQL Server 2008 R2 (standard or express edition) using noexpand hint?

This other article on SQLServerCentral seems to suggest that yes, NOEXPAND continues to work perfectly on every edition of SQL Server from 2005 to 2012. I'll quote:
"Then NOEXPAND hint still works in non-Enterprise editions of SQL Server. I think there has been some confusion as to what this hint actually does. It forces the query optimizer to rely on the view, rather than the underlying table, for optimization. It does not force the query optimizer to use any given index on a view.
The sites I found online stating that NOEXPAND does not work did not include any testing methodology, so I can't say why it did not work for them.I can say that it can work in situations where the query optimizer decides the index is useful."

Related

Database partitioning on SQL server 2014 Standard Edition

Can we do database partitioning (not table/view partition) on SQL server 2014 Standard Edition?
By doing database partitioning, I want to place files on different physical drives.
If not possible, please share link from site like Microsoft etc. mentioning that Standard Edition is not supported.
For all I know, in SQL Server you can put one or more tables in a filegroup, but you cannot break one table into multiple filegroups unless you are using partitioning. Since Standard Edition does not allow partitioning, it seems you are out of luck.
Now, I may regret saying this, but...
What you could consider is to mimic partitioning by splitting your stuff into two or more tables e.g. TABLE1, TABLE2, and so on. Then you place each table on a different filegroup. You can even create a view that does UNION ALL with the tables, so your SELECT queries can hit just one thing, though for INSERT or UPDATE you will probably need to go back to the tables.
Of course, this is NOT PARTITIONING, and you lose a lot of the benefits, from partition operations (switch, split, merge) to engine optimisation, to index management and surely other aspects.
In other words, I would not do this unless I know exactly what I'm doing.

SQL Server NOEXPAND with indexed view

I've been researching a bit on the use of indexed views and the noexpand hint in SQL Server and needed some clarification. Let's assume for this example you have two situations.
An indexed view is created against a table which already has an index created for the underlying table
An indexed view is created against a table which does not have an index created for the underlying table.
If we omit the noexpand hint, will SQL Server utilize the the view index in either situation? Or is noexpand only applicable when the table has an index and there is a choice to be made?
Secondly, does this behavior vary between editions of SQL Server? Has anything changed in 2012?
Depending what message board, blog, or MSDN documentation you read, it's a little unclear.

SQL Server indexed view matching of views with joins not working

Does anyone have experience of when SQL Server 2008 R2 is able to automatically match indexed view (also known as materialized views) that contain joins to a query?
For example the view
select dbo.Orders.Date, dbo.OrderDetails.ProductID
from dbo.OrderDetails
join dbo.Orders on dbo.OrderDetails.OrderID = dbo.Orders.ID
Cannot automatically be matched to the same exact query. When I select directly from this view with (noexpand) I actually get a much faster query plan that does a scan on the clustered index of the indexed view. Can I get SQL Server to do this matching automatically? I have quite a few queries and views and I do not want to reference the indexed view manually each time because I am using an OR mapper.
I am on enterprise edition of SQL Server 2008 R2.
Edit: I found the solution. SQL Server 2008 R2 does not match indexed views with more than 2 joins automatically. Probably it would slow down the optimization process too much.
Edit 2: Reviewing this 2 years after the question was created by me, I don't think my conclusion was correct. Materialized view matching is a very fragile process with no clear rules that I could find over the years.
Certainly, the following play a role:
Number of joins
Presence of a predicate
Join order, both in the view and in the query
I'm a little fuzzy on exactly what your question is; but I think this will give you what you want:
http://msdn.microsoft.com/en-us/library/ms181151.aspx
There are a lot of strange, arbitrary-seeming conditions that limit when SQL Server will use a view index in a query. This page documents them for SQL Server 2008.

Sql Server Management - Option to avoid scripting the collation?

I have databases with different collations. I want to be able to script out tables from one database and create them in another. However, when I script out the tables, it includes the collation in the column definitions.
Is there a way to exclude the collations from the generated table creation scripts?
Tools -> Options
Under Scripting (in the Table/View section)
Set Include Collation to False!
Pretty lame - but do a search and replace on the script after it has been generated??
Which version of SSMS are you using? The full edition, or Express edition?
You'll need to apply at least SP2 for 2005 to get the scripting settongs under Tools->Options.
This doesn't need to be applied to the database servers, it can be applied to just the client tools on your admin workstation if required.

Is there a dynamic management view in SQL Server 2005 that pertains to column statistics?

The dynamic management views of SQL Server 2005 can give usage information about table indexes. Is there a similar method for getting usage information about column statistics? In specific, I'm curious if some of the older column statistics I've created are still being used. If not, I'd like to delete them.
no there isn't. there are however sys.stats_columns and sys.stats catalog views

Resources