question

Kismet110 avatar image
Kismet110 asked

Changing ID to match business requirement.

Hi I've just joined so apologies if this question is in the wrong section! I'm a PROD DBA with little background in dev, came from an infra beginning. I've been asked to change a table that has PK/FK relationships to a couple of other tables so when the data is presented in a web front end the order of a drop down changes. EXAMPLE - Currently in the dropdown the order of items is LONDON, CAMBRIDGE, EXETER, ABERDEEN. The requirement is to have these in the sequence EXETER, ABERDEEN, LONDON, CAMBRIDGE. I can see the data is currently sorted in order of the PK which is fine and if it were a standalone table it would be easy to just DELETE the data then add it back in in the required sequence (is thankfully only a few records in this table and the tables it is linked to via PK/FK) but how to neatly do this without breaking DR in this table and it not having an adverse effect on the related tables? Let me know if you need the TSQL for the tables and any other information. My idea was to create the new tables, pump in the data, test in DEV then if OK cut over to the new tables by dropping the old ones and adding the new ones but if there is an easier/saner method (Im sure there is) please let me know. Cheers
tables
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
@SQLShark avatar image
@SQLShark answered
Can you just add a new column with the desired sort order and let the application handle the order that way.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kismet110 avatar image Kismet110 commented ·
I'm SOOOOO glad you said that because that's exactly what I said to my manager! It's only a handful of records so this would be a no brainer, just get the app side amended so it sorts on this new simple column with asc numbers.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.