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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Odd Question - Can Computed Field Be Primary Key?

Status
Not open for further replies.

HenryE

IS-IT--Management
Apr 30, 2002
42
US
Hi All,

Is it possible to use a computed field as the primary key for a table in an ADP or in pure SQL Server?

For example, say I have two fields in table Names: FirstName and LastName, and I create a field TotalName, which is FirstName+LastName.

Is it at all possible to use TotalName as the primary field for table Names?

Actually, I was able to do this, but it made table Names a read-only table, with no possibility of adding or changing data. So what I am really asking is if it is possible to create primary key field TotalNames in such a way that table Names is not read-only.

Thanks much.

Henry
 
Henry,

The type of Key you are refereing to is possile and is called a "Complex Entity".

You still however need to maintain Uniqeness in your Key, and combining names as a primary key would be fundamentally flawed... how many John Smiths will your DB have to store?

As to making it read only, i'm not sure.

Leigh Moore
LJM Analysis Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top