Joey Lozano
Joey Lozano

Reputation: 1

ALTER PK FROM VARCHAR TO INT

I have a table with a PK of varchar(20). I was thinking this was the thing that drags down the speed of my queries (haven't checked but had a lot of reading about varchars as PKs).

The things is, I'd like to replace the column into an INT (Identity) but it has referential integrity constraints from it.

Is there some easy tasks to do it because if there is not one, I'd do it one by one letting the CASCADE Update do the rest of updating.

PS: Using MS SQL Server 2008

Upvotes: 0

Views: 73

Answers (1)

Remus Rusanu
Remus Rusanu

Reputation: 294287

haven't checked but ...

Measure before you cut. Always. If you have a performance problem, investigate it as a performance problem. Use a methodology like Waits and Queues. Read about Understanding how SQL Server executes a query.

For the record: the chances of the performance problem root cause to the use of VARCHAR(20) are basically 0 (Zero).

Upvotes: 1

Related Questions