Helping you solve those tough coding problems!
Learn some great web development and web design tips and techniques through recipes that clearly define the problem being solved with a working solution.
Popular Tags: cakephp | theory | optimization | javascript-development | asp-net | css | jquery-development | sql | ajax | c

Follow @endyourif rss Facebook LinkedIn

Preventing race conditions with sp_getapplock Preventing race conditions with sp_getapplock

Published on Apr 17, 2019 by Jamie Munro

I am a big proponent of storing calculated fields in the database opposed to calculating them each time they are displayed. They only change at specific times so you just need to cover those spots to calculate them. The danger with storing calculated fields is that concurrent calls have a chance incorrectly calculating the field. Languages such as C# offer the ability to lock objects to help with this. However, in a multi-server example, locking on a single server will not work. In this article I'm going to demonstrate how to use sp_getapplock to prevent race conditions.

Read more >

Tags: SQL | Entity Framework | ASP.NET | mssql | sp_getapplock

Delete duplicate rows with MySQL or MSSQL Delete duplicate rows with MySQL or MSSQL

Published on Feb 27, 2019 by Jamie Munro

The following article will provide a single SQL query that will delete rows that are duplicated in your table. Before you begin, be sure you've tracked down the bad code that is causing this; otherwise, you will need to run it multiple times!

To start, I will create a basic table structure that will help understand the SQL query:

Read more >

Tags: SQL | mysql | delete | mssql