Say I have a simple table that has the following fields:
- ID: int, autoincremental (identity), primary key
- Name: varchar(50), unique, has unique index
- Tag: int
I never use the ID field for lookup, because my application is always based on working with the Name field.
I need to change the Tag value from time to time. I'm using the following trivial SQL code:
UPDATE Table SET Tag = XX WHERE Name = YY;
I wondered if anyone knows whether the above is always faster than:
DELETE FROM Table WHERE Name = YY; INSERT INTO Table (Name, Tag) VALUES (YY, XX);
Again - I know that in the second example the ID is changed, but it does not matter for my application.