Sorry the title is not very descriptive but it is a tricky problem to word.
I have some data, about 200 or more rows of it, and each row has a PacketID, so several rows belong in the same packet. What I need to do, is convert all the PacketIDs from (Example – BDFD-2) to just a number (Example – 1) so all the entries with a packet identifier x need to have a packet identifier of say 3. Is there an SQL query that can do this? Or do I just have to go through manually.
You asked about a query. I wrote a quick VBA procedure instead just because it was so easy. But I’m unsure whether it is appropriate for your situation.
I created tblPackets with a numeric column for new_PacketID. I hoped that will make it clearer to see what’s going on. If you truly need to replace PacketID with the new number, you can alter the procedure to store
CStr(lngPacketID)to that text field. So this is the sample data I started with:And this is the table after running the procedure.
And the code …
I think an approach like that could be fine for a one-time conversion. However if this is an operation you need to perform repeatedly, it could be more complicated … especially if you need each PacketID replaced with the same number from one run to the next … eg. BDFD-2 was replaced by 1 the first time, so must be replaced by 1 every time you run the procedure.