table1
id1 ==> number
id2 ==> number
id want id1 contain uniqe number and id2 contain unique number.
how can set id1 and id2 primary key
?
In Table Designer, click the row selector for the database column you want to define as the primary key. If you want to select multiple columns, hold down the CTRL key while you click the row selectors for the other columns. Right-click the row selector for the column and select Set Primary Key.
If you're asking if a table can have multiple columns as a primary key, then for MS SQL Server, the answer is yes, and it's called a composite (corrected) key.
In the Table Designer, Select both rows, and then click the Primary Key button in the Toolbar.
OR, open the Query Designer, change the view to SQL View, and type the following code:
ALTER TABLE your_table_name ADD CONSTRAINT your_pk_name PRIMARY KEY(id1, id2);
Then, hit the run button. This will create a Primary key which includes both of those fields.
If you are asking about having an Auto-incrementing integer field in both columns, you can't. You would have to do that programmatically. Access (and most other db's) only allow one "autonumber" field per table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With