This blog is about everything and anything. Generally I blog if I feel strongly about something or if I am inspired about something. I love responses, and would love to see that more people read my blog in the times to come! I hope that this note finds you in best of your health! Cheers! Aditya

Wednesday, May 12, 2010

The problem of Unique Records

Hi All!

with 40 visits in nearly one year, and to add insult to injury, most of them have been by me, there is very little one can say about 'All'.

We ran into a very different problem recently. We have an application on a vehicle from which we are extracting the data using a hand-held device. The hand-held device communicates with the truck mounted device using RS-485 communication protocol.

The hand-held device is then brought to the computer where it transfers the data to the computer using USB port. 

The hand-held device has some issues. In the sense that there is a chance that it can send the same data to the computer multiple times. 

The computer software is a VC++ application connecting to Access database using ODBC. We decided to remove the multiple records from the database by running the following queries on the database:

Step 1:

All the records reside in the table Consumption.

We created a table to hold some data temporarily by name of CMPNTMP2. 

We deleted all the records in the table using the query command:

DELETE * FROM CMPNTMP2

Step 2:

Next we selected all the distinct records from the main consumption database and copied them to the temporary CMPNTMP2 table using following query:

INSERT INTO CMPNTMP2 SELECT DISTINCT * FROM CONSUMPTION

Step 3:

Then we deleted all the records in the consumption table:

DELETE * FROM CONSUMPTION 

Step 4:

And finally we copied all the records in the CMPNTMP2 table to CONSUMPTION Table:

INSERT INTO CONSUMPTION SELECT * FROM CMPNTMP2

And Wallah! we had all the unique records!!!

Do visit our site: www.indiaadityanetworks.com to see what we do!

Do drop in a message or two, that will keep us going


No comments:

Post a Comment