August 5, 2020
SQL Server

How to modify a SQL Server function?

How to modify a SQL Server 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

SQL Server

How to create a SQL Server function?

How to create a SQL Server function? For example, the SQL Server function below takes the customer number as a parameter and returns the customer name. Indeed, the function stores the customer name in the Customer Name variable, and it returns it as a result. How to create a SQL

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

SQL Server list all the tables and disk space

List all existing tables from an SQL Server database can be very convenient especially to analyze the disk usage and the free disk space used by each table. Three different ways, but similar are presented here to display SQL Server tables and disk space used by each table. The third solution

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

SQL Server

List User Defined Table Types with SQL Server

How to list User Defined Tables Types of your SQL Server database? First of all, users declare User Defined Table Type as a particular table structure in the database. A database user declares it and not the system. It’s good to ensure users can’t insert data with different types or

SQL Server Views

How to create a SQL Server view?

How to create a SQL Server view to display specific columns from an existing table? Consider a view as a virtual table defined by a SQL query. It’s a set of columns and rows from a table. A user defined view is a view created by a SQL Server developer.

MS BI Abbreviations

XMLA – Extensible Markup Language for Analysis

XMLA stands for Extensible Markup Language for Analysis. It’s a language built on top of XML language. It allows data access from standard multidimensional data sources. Client applications accesses Microsoft SSAS cubes and tabular models using the XMLA language and the HTTP protocol. XMLA stands for Extensible Markup Language for

SQL Server Views

How to delete a SQL Server view?

How to delete a SQL Server view from the database? For a SQL developer it’s a good practice to have a clean database and remove the unused or useless code. Unlike the tables, the views can be deleted from the database using a SQL command. How to delete a SQL

DAX functions

How to calculate year to date value in DAX?

How to calculate the year to date value of the sales in DAX? To calculate the year-to-date value with a DAX formula, use the built-in function called TOTALYTD. In this example, simply copy paste the code and adjust it to your needs. How to calculate the year to date value

No Picture
SQL Server Functions

How to delete a SQL Server function?

How to delete a SQL Server function? This SQL command delete the SQL Server function. However, it does not check if the function exists. How to delete a SQL Server function? Use this T-SQL code to delete the function from the database, the function will be permanently deleted. To avoid errors in

SQL Server Functions

How to call a SQL Server function?

How to call a SQL Server user defined function? The SQL syntax to call a function is different from the call to a stored procedure. Use SQL Server function the same way you select data from a table. How to call a SQL Server function? A SQL Server user-defined function

SQL Server Tables

How to delete a SQL Server table?

How to delete a SQL Server table? How to drop a table without checking if the table exists? Assume the object is already in the database. How to delete a SQL Server table from the database with a query? Here is a SQL script to create a SQL Server table.

SQL Server Errors

SQL Server Truncate Table Error Cannot find the object

In SQL Server, to clear the full content of a table, the fastest way is to run a Truncate Table query. The Truncate is different from the Delete From query because it empties all the lines in the table without a Where clause, it’s a DDL SQL operation (Database Definition

No Picture
SSAS Tabular Errors

SSAS Tabular Model error opening

When opening an SSAS Tabular Model Visual Studio SSDT (SQL Server Data Tools), if for example you loose your network connectivity to the repository for a few seconds, then the SSAS Tabular Model don’t open. Error: Can’t open the SSAS Tabular Model from Visual Studio SSDT. Tabular Model Designer error: