Last post Feb 20, 2017 01:00 PM by PatriceSc
Feb 17, 2017 06:34 AM|saffy|LINK
In a table, we have created Cluster index on one column (Non unique data) MS SQL table, without primary key.
Now can we add a primary key with two columns it it?
Feb 17, 2017 10:09 AM|PatriceSc|LINK
I don't see why you couldn't. What happens if you just try or which problem do you have if you tried already?
Feb 19, 2017 05:26 AM|saffy|LINK
Thank you for your reply.
My question was in-complete, missed the main point.
Yes we are able to create Primary key with two columns.
That primary key has two column
2. Date time.
We are able to create primary key on above two columns. But will be there any performance issue due to Datetime column?
Feb 20, 2017 03:20 AM|Chris Zhao|LINK
The good choice is a composite key of date and identity - in that order (date, identity).
Feb 20, 2017 04:44 AM|wmec|LINK
Yes, we can have more than one column to a Primary key.
Feb 20, 2017 01:00 PM|PatriceSc|LINK
It might be rather the varchar column depending on its size but do first what makes sense. If the varchar column is quite short, at best you'll see a difference if you have a huge number of rows and a huge load where every small enhancements does matter.
Don't optimize too early. Do first what makes sense and just avoid obvious design issues.