| Author |
Topic |
|
cecilvcj
Starting Member
1 Post |
Posted - 2011-05-25 : 08:19:27
|
| Hi,I'm new bee to SQL.plz help to create.How to create two identity in One TABLE ?cecil vcj |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-05-25 : 08:36:45
|
| You can't. There can only be one identity column in a table.Why do you want two?--Gail ShawSQL Server MVP |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-05-25 : 21:36:04
|
| IDENTITY is the count of PHYSICAL insertion attempts (not successes) to a table. It is also not a column; it is a table property. Logically, you can only have one. A good SQL programmer will never use it because it is not part of a LOGICAL database design.--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-05-26 : 06:45:34
|
| Guess I'm not a good SQL programmer then...Like everything, it has it's place and can be used well or misused terribly.--Gail ShawSQL Server MVP |
 |
|
|
jfarrugia
Yak Posting Veteran
55 Posts |
Posted - 2011-05-26 : 06:47:15
|
| if you mean having two columns as identity you can use a composite type p.k.. just select two columns, right click, set as p.kWhere software development knowledge meets the reader |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-05-26 : 07:33:18
|
| You can create an identity then use a computed column or view to emulate another one based on it.Why you would want to do this is another question (and you probably wouldn't).As to PK - and identity and PK are different things. A composite PK is something different to two identities also. Not really connected at all.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jfarrugia
Yak Posting Veteran
55 Posts |
Posted - 2011-05-26 : 08:14:29
|
| yes you can have an identity column which is not a p.k.. however i assume that cecilvcj was referring to p.ks? if not, my bad.Where software development knowledge meets the reader |
 |
|
|
Bazalddo
Starting Member
22 Posts |
Posted - 2011-05-26 : 08:49:47
|
| Cecil,I think it would be much easier for people to help you if you gave us the reason why you need two identity columns....BazShahbaz AhdiApps DeveloperODEON/UCI Cinema |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
|
|