Reputation: 941
I've a SMS Machine that every time a message arrives it makes a POST to a page that fill a SQL Server database table. The text of the messages are like this:
#MessageType#Variable1:Value1,Variable2:Value2,Variable3:Value3
Now that I have the message text I've to parse it to get the values and fill another table. What is the best practice to parse the message? Directly in the code-behind where the SMS Machine POSTs? In SQL Server with a trigger?
Considers that I will receiveon the same SMS machine many message type with diffent variable
Upvotes: 0
Views: 424
Reputation: 2984
Normally it is so that you want to avoid giving the database server more load than it already has (I've seen cases where this is not the case but normally it is so).
Thus it is almost always better to do things like that (formatting text that is to be inserted into the sql server) directly when inserting it (thus at the location of the server that processes the POST.
In your case you have 2 options there that can be used to transform the text into appropriate values for your database:
Normally regex is prefered except if the programmer is not very experienced with regex expressions then normally the 2nd method is used there (regex can be quite troublesome if you are not used to them)
Upvotes: 1