views:

69

answers:

2

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
And unique constraints can be applied as well so that's 99% of the way there.
Martin Smith
Yes, once the clustered index is in place, other indices can be added - including unique indices
marc_s
+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
A: 

No, I don't think so.

ZEAXIF