views:

43

answers:

2

Is there a way to give a view a primary key in sql server. I know it is possible in oracle.

I am not concerned about updates its a read only view but someone else is using it in ms access so I would like the constraint that I know to be correct to be shown.

+2  A: 

Yes, you can create an indexed view, which must have a primary key. Note, this will persist the view data to disk, which may or may not be what you are looking for.

Also, creation of indexed views can also impact performance, both positively and negatively. Make sure you read up on the pros, cons, and limitations thoroughly before implementing.

RedFilter
A: 

Indexed view is the correct choice but a primary key as RedFilter said is not actually required. Though there are many requirements that you will be forced to have such as a clustered index.

The first index created must be a unique clustered index - which is probably what RedFilter meant by primary key?
Chris Diver
I believe that is what he meant by it, but it can be confusing. If I could add comments I would have pointed it out by comment rather than by answer.