Is it possible to set a primary key to a view in SQLServer 2008?
+5
A:
You can create a clustered index on a SQL Server view - it's called an indexed view.
See Improving Performance with SQL Server 2008 Indexed Views for details.
marc_s
2010-06-17 14:49:07
And unique constraints can be applied as well so that's 99% of the way there.
Martin Smith
2010-06-17 15:07:16
Yes, once the clustered index is in place, other indices can be added - including unique indices
marc_s
2010-06-17 15:16:08
+1: SQL Server calls it an indexed view, but it's generally referred to as being a Materialized View. But there are constraints to materialized/indexed views: http://technet.microsoft.com/en-us/library/cc917715.aspx#XSLTsection126121120120
OMG Ponies
2010-06-17 15:39:32