0

I have created this table:

create table UserQuestion
(QuestiuonID int identity,
UserID uniqueIdentifier primary key foreign key references aspnet_Users(UserId),
QuestionTitle Nvarchar(max),
QuestionContext nvarchar(max),
)

I have a problem with it. It looks like I cannot have two fields, where field no. 1 is set as Identity and another one set as Primary.

Is there any way that I can make a table like this that works?

My second question is: what is the benefit of using a foreign key when it's not fetching the data from other table, and I have to give the value to this field manually in my program?

Hossain Ehsani
  • 385
  • 2
  • 16
  • 1
    Possible duplicate of [Can I have multiple primary keys in a single table?](http://stackoverflow.com/questions/217945/can-i-have-multiple-primary-keys-in-a-single-table) – Ted Nyberg Aug 30 '16 at 13:27
  • Improved code formatting, and tightened up the prose (spelling, grammar, etc) – Vince Bowdren Aug 31 '16 at 17:10

0 Answers0