Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary key on view?

Status
Not open for further replies.

JontyMC

Programmer
Nov 26, 2001
1,276
GB
Is it possible to put a primary key on a view in SQL Server 2000?

Jon

"I don't regret this, but I both rue and lament it.
 
I don't want to index it, I just need it to have a primary key.

Jon

"I don't regret this, but I both rue and lament it.
 
what's a primary key but a clustered index?

from BOL

When you specify a PRIMARY KEY constraint for a table, Microsoft® SQL Server™ 2000 enforces data uniqueness by creating a unique index for the primary key columns. This index also permits fast access to data when the primary key is used in queries.

Denis The SQL Menace
SQL blog:
Personal Blog:
 
I'm using some .Net code (that I can't change) which requires tables to have a primary key. I would like to use a view, but can't because I don't know how to assign a primary key. I just want to know if it's possible.

Cheers

Jon

"I don't regret this, but I both rue and lament it.
 
Do all the tables in the view have a primary key? Then just use the SQl that the view uses instead of the view. You can't put primary keys on anything except tables.

Questions about posting. See faq183-874
Click here to help with Hurricane Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top