T-SQL

SQL Server stored procedure with parameters

How to create a SQL Server stored procedure with input parameters? As a reminder, a stored procedure groups and schedules a set of SQL or T-SQL commands. How can we integrate a SELECT query on the Customers table of our SQL Server database into a stored procedure? For example, instead of displaying all the data in the table, to display a single customer, we

Power BI tutorials

Year-To-Date value with Power BI and DAX

How to calculate a year-to-date value of the sales in DAX with Power BI? Also called YTD, it represents the total to date of a given measure. For example, to calculate the year-to-date sales total with a DAX formula, use the built-in function called TOTALYTD. From this example, easily copy and paste the code and adjust it to the data analysis and reporting requirements.

IT Concepts

Dimension table in Data Warehousing

What is the definition of a dimension table in data warehousing models? In business intelligence, dimensions are axes of analysis. The same dimensions often come up in the same areas. A dimension is a tree, the objective is to join facts to a leaf. With this join, analysts can calculate an aggregate with a node, a branch or the whole tree. A dimension in

T-SQL

SQL Server Substring query

What is the T-SQL syntax to split a text field with the SQL Server SUBSTRING query function? This function essentially allows you to split text and select only a part of a string. Example of a SQL Server SUBSTRING query First, the SUBSTRING text function is equivalent to the SUBSTR function in non-Microsoft SQL languages. It allows you to split a string of characters.

T-SQL

SQL Server insert into from a select

How to write an Insert into query from a Select with SQL Server? There are three solutions for running an INSERT INTO query with a SELECT in SQL Server. The first solution is to insert the data with a SELECT query that returns the information in hard copy. Then, the second solution is to use a SELECT and a UNION ALL to group several

T-SQL

SQL Server stored procedure

How do I create and run a stored procedure in SQL Server ? A SQL procedure is nothing more than T-SQL code stored in a way that can be easily reused. In this short SQL Server tutorial here is how to create a simple stored procedure in Transact-SQL? Before creating a stored procedure, you need to know what the end result will be. In

T-SQL

CREATE TABLE with SQL Server

Here is an example of a SQL Server Create Table script to create a customer or sales table. This T-SQL code is a Data Definition Language (DDL) or Data Definition Language (LDD) script. These tables are used as examples in many of the Transact-SQL articles on the Expert-Only site. These simple scripts first test if the table exists, if it does then it is

T-SQL

List all SQL Server tables with a query

To display a list of all SQL Server tables of a specific database, several solutions are possible. Indeed, to audit a MSSQL database and its tables, it is common to want the list of tables in the form of a table or an Excel spreadsheet. SQL Server developers also often look for tables, for example for impact analysis. Thus, all the solutions presented in

T-SQL

SQL Server UNPIVOT

How to use a SQL Server unpivot query to transform columns to rows? It’s possible with this simple T-SQL un-pivot function example. The T-SQL Unpivot function can do it in one single query. It is the exact opposite of the PIVOT query. In this example, only the six first months of the year are used as columns, namely January to June. But you can