December 12, 2019


SQL Server queries



SQL Server

SQL Server Alter Function

How to update the code of an SQL Server function without deleting it? The solution is to update its definition using the SQL Server Alter Function command. The query updates the function already created in the database. This new code returns not only the customer name, but also the customer

SQL Server

SQL Server Create Function

How to write an SQL Server Create Function query? This SQL Server function takes as a parameter the customer number and returns the customer name. Indeed, the function stores the customer name in the @CustomerName variable, and it returns it as a result.   SQL Server Create Function The different steps

SQL Server

Remove SQL Server new line

How to remove SQL Server new line? This post propose a simple SQL Server query to process a string variable and remove the new line character. Technically we replace the new line by nothing. The SQL Server code for a new line is CHAR(13)+CHAR(10).     You want to remove it to

SQL Server

Display SQL Server date full month name

How to display SQL Server date full month name? Which is to say with the complete month names like January, February, March, April, May, etc. written out in full. This query shows you how to get the full month names from the current date or any other date.   Indeed,

Blue and grey gearwheels image
SQL Server

SQL Server UNPIVOT function example

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

SQL Server

Check SQL Server table last update and access

How to check SQL Server table last update and access? Check the last access and update with a simple SQL query? Thanks to SQL Server RDBMS system tables, a query allows you to display the last changes done. We can apply it to any SQL Server table or view, like

SQL Server

SSMS option to check object existence in SQL scripts

How to add or remove the object existence checks in SQL creation scripts with SQL Server Management Studio? To add dynamically the existence check before generating the create statement for you SQL Objects like tables, views,  functions or stored procedures, it’s easy. Simply activate this SSMS option to check object existence in

No Picture
DAX functions

Calculate Last Year Value in DAX

How to calculate the last year value in DAX? Simply use use the available DAX CALCULATE function combined with the DAX PREVIOUSYEAR function. In financial Dashboard and Reports, use the previous year value for comparison and variance calculation with the current year. How to calculate the last year value in DAX using the PREVIOUSYEAR formula? We can use directly the value from an

No Picture
MS BI Abbreviations

DAX – Data Analysis Expression

DAX stands for Data Analysis Expression, it’s the Microsoft language to manipulates data in Microsoft SSAS Tabular cubes as well as in Power BI, and also in Excel PowerPivot. DAX: Data Analysis Expression The DAX library is a Powerful and user-friendly Microsoft library of different type of functions addressing different

SQL Server Errors

SQL Server Database does not exist sp_MSforeachdb

With SQL Server, when using the sp_MSforeachdb system stored procedure, the system displays this error “Database does not exist. Make sure that the name is entered correctly.” . The stored procedure displays the error because the database tries to access a database that does not exist in your SQL Server

SQL Server

SQL Server Alter Function

How to update the code of an SQL Server function without deleting it? The solution is to update its definition using the SQL Server Alter Function command. The query updates the function already created in the database. This new code returns not only the customer name, but also the customer

SQL Server

SQL Server Create Function

How to write an SQL Server Create Function query? This SQL Server function takes as a parameter the customer number and returns the customer name. Indeed, the function stores the customer name in the @CustomerName variable, and it returns it as a result.   SQL Server Create Function The different steps

SQL Server Tables

SQL Server Drop Table only if exists

How to drop a SQL Server table only if exists? How to drop it only if the existence check shows it already exists in the database to avoid errors, using the DROP TABLE keyword. Indeed when running long SQL scripts or running scripts twice, it is much better to test

SQL Server

Remove SQL Server new line

How to remove SQL Server new line? This post propose a simple SQL Server query to process a string variable and remove the new line character. Technically we replace the new line by nothing. The SQL Server code for a new line is CHAR(13)+CHAR(10).     You want to remove it to

SQL Server Functions

SQL Server user-defined functions example queries

SQL Server user-defined functions are very useful when you start T-SQL development on SQL Server. You need to use them very often so you have to learn the right syntaxes and avoid errors. At the beginning it can be tricky and frustrating because it’s binary, it work or don’t work, programming T-SQL