Should I add another column? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Should I add another column?

If a table has many columns but none of the columns are unique, in order to select a record, it always requires the combination of few columns. I wonder whether I should add another column which will contain unique value and set this column to be primary key so it is possible to select a record by using that key. If yes, should this be done only if the # of columns are certain number?
Thanks
If a combination of existing columns can make the row unique then use that scenario. If you’re looking for a single column solution and none of the existing columns work then adding an auto incrementing identity column would work. Depending on the data stored a table you may end up with more than one column as a unique primary. Dbu
All postings are provided “AS IS” with no warranties for accuracy.
it’s all depend on your data.
there can be a instance where you can make a composite key ans a uniques key.
if you introduce an idenitity column, still how are you going to link that with data .
SO I think better way is to identify a composite key for the data
quote:Originally posted by pcsql If a table has many columns but none of the columns are unique, in order to select a record, it always requires the combination of few columns. I wonder whether I should add another column which will contain unique value and set this column to be primary key so it is possible to select a record by using that key. If yes, should this be done only if the # of columns are certain number?
Thanks

And beware that you do not create a unique composite index, and add the IDENTITY column, and add that column to the unique composite index. In that case, your unique composite index would no longer be necessarily unique on the non-identity columns.
]]>