Why you should do database stuff in the database.

Today, I had a need to programmatically update data in one database from another database.  I wrote a quick .NET app to pull the data out of one table, process the data, and put it into another table in another database table.  I just went to write a quick utility because I was running in two databases.  I didn't check the amount of data, but I saw that this was really slow.  As the data ran through the triggers, it was way to slow.  it was taking about 2 seconds for each record.  It would have resulted in approximately 2 days of processing.  Well, that was not acceptable.  I pulled up my SQL Server Books Online and grabbed a couple of TSql commands.  The resulting TSql command took 16 seconds to run.  Moral of the story, if you can do it in the database, you should probably do it in the database.



Comments have been disabled for this content.