How to swap the values of two columns of a table ? Let me explain the scenario with an example - Let's create a table named "Employees" with columns "First_Name" and "Last_Name". Then populate the table with some fictitious data. Then view the results once and then interchange the values in the "First_Name" and "Last_Name" columns... Continue Reading →
Calculation of metrics at database level or reporting level..? which is the best way..?
I just came across a same old situation of deciding where to do the calculation of certain metrics like percentages ? Here is my take on it with a fictitious example - Scenario 1: Calculating it at database level and preserving it in the database: see Fig.:1(Associate Level Sales) showing a table with sales made by a few sales executives... Continue Reading →
Comparing datetime column with a date literal in T-SQL
Hi Friends.. I have seen that comparing a datetime column in a table in SQL Server database, that has both date and time parts (e.g. 2012-12-05 10:37:36.897) with a date literal that has only date part is a not straight forward. Let me explain with an example: Have created a temporary table with two date... Continue Reading →