Tag Archives: SQL

Calculating Statistical Values in T-SQL: Mean (Average), Median, Mode and Range

Sometimes you may need to calculate statistical values based on a set of values you have in a table. Let’s start with explaining what these values represent, in case you don’t already know. For the purposes of this post, we … Read More »»»

Posted in MSSQL | Tagged , , , , , , , | Leave a comment

How to Trash/Spam All Unreviewed Posts in WordPress (MySql Way)

If you ever got too many comments that you feel are undesired (usually spam, or all) and need to do so, here is an easy way to do this: log in to your MySql database and run the following statement: … Read More »»»

Posted in Quick Tips, WordPress | Tagged , , , , , | Leave a comment

Find a String Value in the Whole Database: Searching for Text in Tables and Columns

Once in a while you may come across a problem when you are not familiar with the database structure you are dealing with. You may have to deal with the front end only and values that are only presented to … Read More »»»

Posted in MSSQL | Tagged , , , , , , , , , , , , , | Leave a comment

How to Calculate the Number of Seconds Since Last Epoch (1/1/1970) in T-SQL

In certain situations, you may need to calculate the number of seconds that have passed since the start of the epoch. In computer world, the start of the epoch most often refers to the Unix epoch, also known as Unix … Read More »»»

Posted in Quick Tips | Tagged , , , , , , , , , , | Leave a comment

Avoiding Deadlock Transaction Errors by Using ROWLOCK Hint in T-SQL

When updating a single row data in a table, it may take a nasty while if the table is big and you have a condition in a WHERE clause on a column that is not indexed. In this case SQL … Read More »»»

Posted in MSSQL | Tagged , , , , , , , , , , , , | 1 Comment

How to Use NOLOCK and ISOLATION LEVEL to Optimize T-SQL Query Performace

In this article, we will discuss how a NOLOCK hint can help improve performance of queries. Suppose you have a table: CREATE TABLE Users ( UserId INT PRIMARY KEY IDENTITY(1, 1) NOT NULL, FirstName NVARCHAR(50) NOT NULL, LastName NVARCHAR(50) NOT … Read More »»»

Posted in MSSQL | Tagged , , , , , , , , , , , , | 1 Comment

Saving Bulk Modified or Deleted SQL Database Data for Recovery

Sometimes you need to modify or remove data in bulk in a SQL database. Whatever the reason is, it is always a good practice to store such changes so that if something goes wrong you would be able to restore … Read More »»»

Posted in MSSQL | Tagged , , , , , , , , , | Leave a comment

Create a SQL CLR Stored Procedure Using .NET (C# Example)

T-SQL is limited in its functions and getting the results you need sometimes becomes very complex and the statements used consequently hard to decipher. With SQL Server 2005, Microsoft introduced CLR (Common Language Runtime) technology which allows you to use … Read More »»»

Posted in C# | Tagged , , , , , , , , , , , , | Leave a comment

How to Deserialize Objects That Are Stored in a Database as XML

You can serialize objects and store them in a database using the .NET framework. How do you get them back, then? – It is a rather straight-forward code. I’m going to utilize the same example classes I used in the … Read More »»»

Posted in C# | Tagged , , , , , , , , , | Leave a comment

How to Persist (Store) Objects in a Database Using Serialization in .NET

Once in a while, you need to persists your objects, that is store them for later use, be it for use across multiple applications or a single application. .NET provides a serialization mechanism for achieving this. So, let’s start off … Read More »»»

Posted in C# | Tagged , , , , , , , , , , | 1 Comment