After some firmware migrations I ended on 2.1 and recognized that my SMS icon shows at least 218 unread SMS messages. I wasn’t able to mark the messages as read, even if I view all of them.
I figuerd out, that the problem persists because of an improper update of the sms.db. The database contains all messages in one table and message groups in the database table msg_group. Each entry in the msg_group table contains an attribute unread_count which is updated implicitely. In my case the problem was, that various message groups hold imporper values for unread_count which where not reset by the corresponding trigger.
Start by syncing the iPhone completely using iTunes (this implicitely creates a complete system backup). Disconnect the phone and start the following. Use the terminal app or connect to your openSSH server to get console access. Change to the the SMS directory.
Disable the phone to reduce the risk of losing any new SMS. Additionally make copy of the existing sms.db.
cp sms.db sms.db.sav
Now open sqlite CLI and try to update sms.db
We are going to set all messages to read by the following command.
update msg_group set unread_count = 0;
Exit sqlite and reboot the phone.
After a successful reboot the unread message indicator should dissappear.