Check if object exists with SSMS

How to add or remove a script to check if an object exists in SQL creation scripts generated with SQL Server Management Studio (SSMS)? 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 your SQL Server Management Studio software. For example,


Create a table in MySQL

To create a table in MySQL, start by connecting to the MySQL server from PHPMyAdmin. Indeed phpMyAdmin (PMA) is the central interface to manage MySQL databases and tables. MySQL is an Open Source database, which means that it is free software. To start, connect to the MySQL server and database from a web browser like Google Chrome or Firefox for example. How to create


SQL Server table size and disk space

Listing SQL Server table size and disk space can be very convenient specially to analyse the disk usage for 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 also shows the number of lines for every table. Get all SQL Server table names with table size and disk


List user defined table types in SQL Server (UDT)

How to list user defined table types in a SQL Server database? First of all, users declare User Defined Table Type as a particular table structure in the database. This UDT is reusable in database, it is not a system table. It’s a good practice to ensure users can’t insert data with different types or length for example. Or even from different data structure.

days of calendar

Last time table was updated in SQL Server

How to check the last date a table was updated on a SQL Server database? Check the last access and update with a simple SQL query? Thanks to the SQL Server relational database management system tables, a query allows you to display the last changes done. We can apply it to any SQL Server table or view, like last scans, or last updates for



How to modify a SQL Server table using the Alter Table command? Simply connect to the server hosting the instance, the database and the table and run an ALTER TABLE SQL Server query. The goal is to update an already existing table to adapt its structure for example. Or the constraints associated to the table. The example script below modify the Sales table previously


SQL Server primary key

How to create a table with a primary key in SQL Server ? A database primary key is designed to allow one unique value to identify a line in a table. First, what is the purpose of a primary key? And moreover, what is the definition of a primary key? A primary key ensures that only one unique line as a specific ID. Script


Alter View with SQL Server

How to alter a SQL Server view with a T-SQL script? This code example allows you to modify an existing view. All you must do is use the common ALTER VIEW command. For example, to delete a column from the existing view or to add a column calculated from other columns in the source table. Modify a SQL Server view with an Alter View


Insert or Update with SQL Server (Upsert)

How to write an insert or update query with SQL Server, also called SQL upsert? Here are two different, quick and easy solutions to write an “UPDATE OR INSERT” query. In other words, avoid the SQL Server error “Cannot insert duplicate key in object”, “The duplicate key value is” because the row in question already exists in the target table. Indeed, inserting the same


Execute a SQL Server stored procedure with parameters

How to execute a SQL Server stored procedure with input parameters? Depending on the implementation of the SQL Server code, call the procedure with all necessary parameters or only one. First you must set the value NULL in the procedure code. This is because we create the parameters in a mandatory or non-mandatory way. For optional parameters, we can assign a default value in