is there more the two primary key in a single table?
Answers were Sorted based on User's Feedback
Answer / vinay singh
There are no more than one Primary Key in a single table,
but we can make a Primary key using combination of more than
one column...
Example..
CREATE TABLE [LoginHist] (
[UserId] [char] (15) NOT NULL ,
[LogDate] [smalldatetime] NOT NULL ,
[ClientIp] [char] (15) NOT NULL ,
[LoginCount] [int] NULL DEFAULT (0),
CONSTRAINT [PK_LoginHist] PRIMARY KEY CLUSTERED
(
[UserId],
[LogDate],
[ClientIp]
) ON [PRIMARY]
) ON [PRIMARY]
** Vinay Singh
** Cell No - 9867774724
| Is This Answer Correct ? | 18 Yes | 1 No |
Answer / sandesh kadam
Guys,
Saying "yes", can you please make efforst in explaining how
to have two primary keys on the table.
Regards
Sandesh
| Is This Answer Correct ? | 12 Yes | 3 No |
In SQL Server 2000,
Query :
-------
create table BookDetails
(
Book_ID int identity(1,1) not null primary key,
Book_Title varchar(20),
Book_Type varchar(15),
Book_Author varchar(25),
Book_Edition float,
Book_Publisher varchar(20),
Book_Pub_Year datetime,
Book_Price int primary key
)
Answer :
--------
Server: Msg 8110, Level 16, State 1, Line 1
Cannot add multiple PRIMARY KEY constraints to
table 'BookDetails'.
Reply Answer:
-------------
So,Can't Create more Primary Keys in a Table.
| Is This Answer Correct ? | 13 Yes | 5 No |
Answer / gowthami radhakrishnan
no only one primary key for a table.but primary key can be
uesd in combination with other key known as composite key.
| Is This Answer Correct ? | 7 Yes | 0 No |
Answer / jahir
refer below, actually its not primary key, Its Composite Key
CREATE TABLE [LoginHist] (
[UserId] [char] (15) NOT NULL ,
[LogDate] [smalldatetime] NOT NULL ,
[ClientIp] [char] (15) NOT NULL ,
[LoginCount] [int] NULL DEFAULT (0),
CONSTRAINT [PK_LoginHist] PRIMARY KEY CLUSTERED
(
[UserId],
[LogDate],
[ClientIp]
) ON [PRIMARY]
) ON [PRIMARY]
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / sivakumar
No, When creating table using script we can create primary
key another one is called composite key that means
combination of more than
one column...
CREATE TABLE [LoginHist] (
[LogDate] [smalldatetime] NOT NULL ,
[ClientIp] [char] (15) NOT NULL ,
[LoginCount] [int] NULL DEFAULT (0),
CONSTRAINT [PK_LoginHist] PRIMARY KEY CLUSTERED
(
[LogDate],
[ClientIp]
) ON [PRIMARY]
) ON [PRIMARY]
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / asas
NO guys
create table prk(eno int primary key, dno int primary key)
Msg 8110, Level 16, State 0, Line 1
Cannot add multiple PRIMARY KEY constraints to table 'prk'.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / vijay
No, more than one primary key in a table
but combination of more than one column in a
primary key
| Is This Answer Correct ? | 4 Yes | 1 No |
How do you persist objects, permissions in tempdb
How to resolve the orphan use problem? : sql server security
What is filtered index?
Suggest a method of joining two tables.
0 Answers Ernst Young, Thomson Reuters,
What are the different types of normalization?
What is store procedure? How do they work? When do you use?
What is the difference between implicit and explicit transaction?
your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files? : Sql server administration
What is the largest component inside a field?
What is the difference between mysql and sql server?
Where the sql logs gets stored?
How to connect a database with sql express.?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)