I’m importing data to a database. About 5000 rows each time. When im inserting into the DB one of the columns has a location. There are about 80 possible locations in total. I want to check each one of those and change it to a list of another 80 location names instead before I insert each row into the database. I have a switch statement helping me at the moment, but I was wondering if anyone thinks that this is a bad way to do it or whether I’m on the right track.
So basically at the moment. When I upload my data, that switch statement needs to be checked and a value changed 5000 times. Is switch the right way to go?
Don’t use a switch statement, very hard to maintain. Create another table in your DB that maps your input location to the required database location and query off that instead. Makes it much easier to update/insert new locations etc, and keeps the length of your script to a sane level.