Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Jadexy
Starting Member
3 Posts |
Posted - 2010-06-18 : 08:47:40
|
| Hallo,I want to create a view with a primary key constraint similar to oracle'sALTER VIEW V_VIEWADD CONSTRAINT PK_V_VIEW PRIMARY KEY(ID)DISABLE NOVALIDATE;Can this be done in SQL Server 2005?Thanks in advance, Jade |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-06-18 : 09:06:59
|
| You can't create primary key constraint for a view in sql server.Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-06-18 : 09:30:08
|
| You can however create unique indexes on views. |
 |
|
|
Jadexy
Starting Member
3 Posts |
Posted - 2010-06-18 : 09:51:50
|
| And how do you mark the primary key columns? |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-06-18 : 10:19:15
|
| It's documented in Books Online under "CREATE INDEX".Keep in mind it's not an actual primary key but a unique constraint, as it may allow nulls. It accomplishes the same goal however. |
 |
|
|
Jadexy
Starting Member
3 Posts |
Posted - 2010-06-18 : 10:21:56
|
| Books online? Where? |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-06-18 : 10:34:19
|
| They're installed with SQL Server in the same Start Menu group as SQL Server Management Studio (Documentation and Tutorials). They're also available online at MSDN. |
 |
|
|
|
|
|