- 16.4k
Cannot truncate table because it is being referenced by a FOREIGN KEY constraint
Using Microsoft SQL Server, you cannot truncate or drop a table with a foreign key constraint. For example, when you have a client table and a country table. When the client table has a foreign key ...
- 11.7k
Calculate Age in SQL Server
In my daily work, I need to calculate and report the age of people very often. There are a couple of ways to calculate the age and will give you the right result. I do not recommend a SQL Function to ...
- 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.
- 5.7k
Calculate Lost Customers using T-SQL
A common question in the Business Intelligence world from customers is "how many customers did we lose this year" ? Businesses wants to know this so they can act faster to keep customers doing ...
- 4.4k
How To Find the slowest SQL Queries
This stored procedure displays the top worst performing queries based on CPU, Execution Count, I/O and Elapsed_Time as identified using DMV information. This can be display the worst performing ...
- 12.5k
Calculate DateDiff With Only WeekDays or Workdays
Today, I was working on a fact table for my datawarehouse. I was looking for a function to calculate the number of " normal weekdays " between two given dates I had a record in my Dwh from a HR ...
- 4k
Reset Ident Column in Database
This is a very handy little script to generate a script to reset the ident column of all your database tables. This can be handy after filling and truncating tables. This script uses a schema "ps". ...
- 4.2k
Script to count nr of rows in all tables
This script can be used as a view to count the number of rows in all SQL tables in your database. This can be very usefull.
- 50.2k
Calculate Weeks Between Two Dates using DateDiff
In SQL Server, there's a buildin function to calculate the number of weeks between two dates. This function is called "DateDiff". The problem with this function is that Sql Server thinks the week ...
- 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.7k
T-SQL Group By ALL
When you type a T-SQL Query, you often want to group the data. Today I came across a neat trick for grouping: the GROUP BY ALL option. It may be a bit hard to explain what it ...
(11 rows affected)
Completion time: