- 7.4k
T-TSQL - Create 4 week Moving Total
This article will offer you a way to calculate a 4 week moving total in SQL using SQL Server. There are more ways to Rome but this is a way you can use to calculate it using a date dimension.
- 6.3k
Calculate time in hours and minutes between two dates
Sounds easy right? I want to calculate the difference in hours and minutes between two dates. A good readable notition for my report. I want a format like this: 00:36:53 OR 02:13:45 This can easy be ...
- 4.2k
After update trigger
Sometimes it is useful to keep track of a modification date or modification user in a field, especially in a master data environment. You can use a trigger on a table for this. It must work both ...
- 4.7k
Calculate the nearest working day
Last week I had a nice challenge. In the KPI table I use for certain reports, only the normal working days are calculated, Monday to Friday. Public holidays are in there too. The ...
- 6.8k
Dutch public holidays in SQL Server
Sadly there is no standard function in SQL Server to check whether a date is a public holiday. To find out, it helps to use a date dimension as explained here ...
- 5.7k
Centralizing KPIs in your data warehouse
You build brilliant reports with the best figures, revenue, productivity and KPIs. Over time more and more reports appear within the organization. Until someone suddenly notices that the ...
- 5.3k
Calculating running totals
A lot has been written about it on the internet already, but I thought it was worth posting an article about calculating running totals in Microsoft SQL Server 2005 / 2008. There are ...
- 3.9k
Script all databases and objects
Following an earlier article about scripting your database objects, I made a stored procedure that scripts all databases for you automatically and writes the script to a ...
- 12.4k
How do I make a date dimension?
Date dimensions are very useful. With a date dimension / date table you can look up for any date which week it falls in, which year, which month, whether it is a public holiday ...
- 20.3k
Date calculations
In SQL Server 2005 you can do date calculations in several ways. SQL Server 2005 has several functions you can use when you work with dates. This article describes a number of ...
- 9.5k
Finding duplicate rows
Every row in a table is identified by a primary key. Now and then the key occurs twice in your system. That should not happen. With this simple query you can ...
- 8.4k
Query Active Directory
It can be useful to include data from your Active Directory (AD) in your data warehouse. In my case it was useful because the customer wanted to see whether a user who had left the company still ...
- 4.7k
Recursive Query with CTE I
I recently ran into a problem that I found interesting enough to put on my blog. It covers a common situation where you use a dataset several times, also called a ...
- 7.4k
Convert a date to an integer
In data warehouse land we use integers as primary keys for the date in our date dimension. So we store the date "2008-12-01 00:00:00.000" as "20081201". This lets you ...
- 18.6k
The 3 best ways - Find a column in a SQL database
You want to find a column in one of the tables in your SQL Server database. Your database has a few hundred tables. Expanding all the tables to look for the column can be a time-consuming job ...
(15 rows affected)
Completion time: