{"id":6474,"date":"2022-02-28T06:00:00","date_gmt":"2022-02-28T05:00:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=6474"},"modified":"2022-12-12T18:25:32","modified_gmt":"2022-12-12T17:25:32","slug":"create-a-sql-server-database-with-a-script","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/dba\/create-a-sql-server-database-with-a-script\/","title":{"rendered":"Create a SQL Server database with a script"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-create-a-sql-server-database-with-a-t-sql-script-in-ssms\">Create a SQL Server database with a T-SQL script in SSMS<\/h2>\n\n\n\n<p>This simple sample script allows to <a href=\"https:\/\/www.codegrepper.com\/code-examples\/sql\/create+database+sql+server+script\" target=\"_blank\" rel=\"noreferrer noopener\">create<\/a> 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.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">USE [master];\nGO\n\nCREATE DATABASE [EXPERT-ONLY];\nGO\n<\/pre>\n\n\n\n<p>The result of the script execution is available below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"174\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2018\/04\/sql-server-create-database.jpg\" alt=\"Create a SQL Server database with a T-SQL script\" class=\"wp-image-4541\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2018\/04\/sql-server-create-database.jpg 502w, https:\/\/expert-only.com\/wp-content\/uploads\/2018\/04\/sql-server-create-database-300x104.jpg 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><figcaption class=\"wp-element-caption\"><strong>Create a SQL Server database with a T-SQL script<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p>Finally, the result is the creation of the [Expert-Only] database with the default SQL Server options. It is now visible under the server \/ instance, here it is localhost. Then select Databases.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"541\" height=\"565\" src=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/07\/create_sql_server_database_visible_ssms.jpg\" alt=\"Sql Server database created with a T-SQL script visible under Databases menu\" class=\"wp-image-8750\" srcset=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/07\/create_sql_server_database_visible_ssms.jpg 541w, https:\/\/expert-only.com\/wp-content\/uploads\/2022\/07\/create_sql_server_database_visible_ssms-287x300.jpg 287w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><figcaption class=\"wp-element-caption\"><strong>Sql Server database created with a T-SQL script visible under Databases menu<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p>It is also possible to <a href=\"https:\/\/expert-only.com\/en\/sql-server-db\/display-sql-server-detailed-version-with-a-query\/\">list display the detailed version of the current database<\/a> with a simple query. To <a href=\"https:\/\/expert-only.com\/en\/sql-server-db\/create-a-database-with-sql-server-management-studio\/\">create a Microsoft SQL database with no script<\/a>, use the SSMS graphic interface.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"230ZCbn59d\"><a href=\"https:\/\/expert-only.com\/en\/dba\/create-sql-server-database-with-ssms\/\">How To Create a SQL Server Database with SSMS ?<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;How To Create a SQL Server Database with SSMS ?&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/dba\/create-sql-server-database-with-ssms\/embed\/#?secret=NkhZ0Nv7WA#?secret=230ZCbn59d\" data-secret=\"230ZCbn59d\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>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 <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/dba\/create-a-sql-server-database-with-a-script\/\" title=\"Create a SQL Server database with a script\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":6379,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[488],"tags":[],"class_list":{"0":"post-6474","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-dba"},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/6474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=6474"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/6474\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/6379"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=6474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=6474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=6474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}