Up until now my foreign keys have always been uniqueidentifiers or an int.
Would it impact performance negatively if I used a nvarchar field as a foreign key? Are there any other considerations I should be concerned about?
Although you can make nvarchar as foreign key but I would not suggest you to use nvarchar as foreign key. There are many reasons out which I think the one which is very essential is when you will be doing JOINS then nvarchar will be slower as compared to int.
Would it impact performance negatively if I used a nvarchar field as a foreign key?
Yes definitely there would be performance issue as an int uses 4bytes of data and is usually quicker to JOIN than NVARCHAR.
You can also check space used by using the stored procedure sp_spaceused
by taking the column as int and nvarchar and you will find the difference.
EXEC sp_spaceused 'TableName'
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