Create a SQL Server database with a script

In order to create a new SQL Server database with one script, just follow this article and especially the code snippet. To create a Microsoft database with a Transact-SQL script, use the CREATE DATABASE function as explained in this post.

First, a database represents the main part of a Relational Database Management System. An RDBMS contains and runs databases. A database contains SQL objects and mainly tables.

How to create a SQL Server database with a T-SQL script ?

This simple sample script allows to create a database with two SQL commands. Please make sure you understand the commands and adapt the script to your specific case, for example the name of the database.

USE [master];
GO

CREATE DATABASE [EXPERT-ONLY];
GO

The result of the script execution is available below:

SQL Server database creation script

Finally, the result is the creation of the [Expert-Only] database with the default SQL Server options:

It is also possible to list display the detailed version of the current database with a simple query.

Be the first to comment

Leave a Reply