Home / T-SQL

T-SQL

Actieve bold buttons maken in Power BI

Wanneer je met buttons werkt in Power BI om bijvoorbeeld met bookmarks te werken is het handig om te zien welke “view” actief is in je rapport. Het lijkt een beetje op het principe van een web navigatie. Door de actieve bookmark op de button zichtbaar te maken wordt het …

Read More »

Setup sp_send_dbmail attachment included!

sp_send_dbmail attachment

I need to setup a weekly report for one of my customers. The report can be manually run by executing a T-SQL statement and copy the result to Excel. After copying, it’s emailed to the client. By using sp_send_dbmail attachment options, you can automate this process.

Read More »

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 to this. SQL Functions are performing very slow, especially …

Read More »

Calculate Lost Customers using T-SQL

Calculate Lost Customers in 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 business with them. In this article, I will help you to create SQL to calculate this …

Read More »

How To Find the slowest SQL Queries

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 queries from an instance, or database perspective.   The number of records shown, the database, and the sort order are identified by …

Read More »

Interesting Course about data visualisation from Google

Making Sense of Data   Do you work with surveys, demographic information, evaluation data, test scores, or observation data? Are you interested in making the data you collect more useful by organizing it, analyzing it, and applying it in different ways? This self-paced, online course is intended for anyone who …

Read More »

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 done using a T-SQL Statement like this: CONVERT(nvarchar(64), EindDatum-StartDatum, 108) AS DurationCONVERT(nvarchar(64), EindDatum-StartDatum, 108) AS …

Read More »

After update trigger

Soms is het handig om een mutatiedatum of mutatieuser bij te houden op een veld, met name in een master data omgeving. Je kunt hiervoor gebruik maken van een trigger op een tabel. Dit moet zowel werken als er nieuwe data wordt ingevoerd als wanneer er data wordt bijgewerkt.

Read More »

Dichtstbijzijnde werkdag uitrekenen

Ik had vorige week een leuke uitdaging. In de KPI tabel die ik gebruik voor bepaalde rapportages zijn enkel de normale werkdagen uitgerekend, maandag t/m vrijdag. Feestdagen komen ook voor. De weekenden zijn hier bewust uitgelaten ivm FTE tellingen die anders niet lekker lopen.

Read More »