SQL and IT tutorials

T-SQL

Return values with SQL Server stored procedure

How to create a SQL Server stored procedure to return values with OUTPUT? This simple T-SQL example returns values through output parameters. Setting up, instantiating, and using the output parameters of a stored procedure is similar to that of the input parameters. The major difference is the OUTPUT clause after the parameter name. The OUTPUT keyword specifies that the stored procedure must return a

T-SQL

Drop SQL Server stored procedures without errors

How to drop a SQL Server stored procedure without error using the existence check? To drop a SQL Server stored procedure and avoid errors, first test the existence of the procedure in the SQL Server database to condition the DROP PROCEDURE command. On the other hand, it is a good practice to always test the existence of SQL Server objects. In this case a

T-SQL

Store a SQL Server column in a variable with delimiters

Query to store the contents of a SQL Server column in a variable, inline and with delimiters. SQL tutorial to read and store the result from a SQL Server column in a variable, and with separators. In some cases, it is useful to get all the values of a column in a T-SQL variable and add a delimiter. How to store the contents of

T-SQL

Format a SQL query automatically and for free

How to format a SQL query automatically with a free online service? Format a SQL query automatically can be time-consuming and tedious, especially on existing projects that are not developed according to the rules of the art. There is a useful website that allows you to format SQL queries. Indeed, it is aimed at SQL development engineers, DBAs, and in general all SQL developers.

T-SQL

SQL Server SELECT queries to select and filter data

Example queries with the SQL Server SELECT function to select, filter and display data. T-SQL tutorial to learn how to use the SQL Server select queries to display and filter data from a table. This is the basic query because SQL, for Structured Query Language, is primarily designed to query and display data from a table. The query is of the type DML for

T-SQL

Test and drop a SQL Server view if it exists in the database

How to test and then drop a SQL Server view, if it exists in the database? Here is how to test the existence and drop a SQL Server view with a T-SQL script. Use this script as an example to test the existence of the view before deleting it. The goal is to not generate an error during the execution of a deployment script

T-SQL

T-SQL procedure with hard coded variables and dynamic execution

How to execute a T-SQL procedure from a text with a hard coded variable? Tutorial to manage and execute a T-SQL procedure with hard coded variables, i.e. stored in a string. Indeed, a normal execution does not work with the EXEC command alone. So how do you get around this error? The solution to the problem is to use the T-SQL EXEC function sp_executesql.

SSIS

Deploy SSIS packages with cmd and the dtutil command line tool

How to deploy SSIS packages with the cmd command line and the dtutil tool? For SSIS package deployments, SQL Server includes the dtutil executable utility that works with cmd command lines, to deploy dtsx files directly with ms-dos. Dtutil.exe is a good choice for scripting and automating the deployment of SSIS projects. It can be run from a command prompt or from a batch

SQL Server Database Administration

Create a SQL Server database with SSMS

Tutorial to create a SQL Server database with SSMS (SQL Server Management Studio). How to create a SQL Server database with SQL Server Management Studio, i.e. SSMS. In this tutorial, let’s learn how to add a new MS SQL database to an instance. Indeed, to start, it’s mandatory to create a database to create and use SQL objects. It is possible to perform almost

T-SQL

Calculate the difference between two dates with SQL Server

Calculate the difference between two dates in hours, minutes, and seconds with SQL Server functions. With the SQL Server time function DATEDIFF, it is possible to calculate the difference between two dates in hours, minutes, and seconds but only in one unit at a time. For example, only seconds, or only minutes or only hours. This SQL Server script uses the DATEDIFF function and