{"id":64,"date":"2016-05-18T00:21:06","date_gmt":"2016-05-18T07:21:06","guid":{"rendered":"https:\/\/database.guide\/?p=64"},"modified":"2020-02-14T16:35:18","modified_gmt":"2020-02-14T23:35:18","slug":"how-to-create-a-table-in-sql-server","status":"publish","type":"post","link":"https:\/\/database.guide\/how-to-create-a-table-in-sql-server\/","title":{"rendered":"How to Create a Table in SQL Server"},"content":{"rendered":"<p>To create a table\u00a0in\u00a0<a href=\"https:\/\/database.guide\/what-is-sql-server\/\">SQL Server<\/a> using the GUI:<\/p>\n<ol>\n<li>Ensuring that\u00a0the right database is expanded in Object Explorer,\u00a0right click on the <kbd><samp>Tables<\/samp><\/kbd> icon and select <kbd><samp>Table...<\/samp><\/kbd> from the contextual menu<\/li>\n<li>A new table will open in Design view. Add the columns, their data types, and column properties.<\/li>\n<li>Save the table (either from the File menu, or by right-clicking on the table tab and selecting <kbd>Save Table1<\/kbd>)<\/li>\n<\/ol>\n<p>The table will appear in the Object Explorer\u00a0under the <kbd><samp>Tables<\/samp><\/kbd> icon for the applicable database.<\/p>\n<p><!--more--><\/p>\n<p>Below are screenshots for the above steps.<\/p>\n<h2>Right-Click on &#8220;Tables&#8221;<\/h2>\n<p>Ensuring that\u00a0the right database is expanded in Object Explorer,\u00a0right click on the <kbd><samp>Tables<\/samp><\/kbd> icon and select <kbd><samp>Table...<\/samp><\/kbd> from the contextual menu:<\/p>\n<figure id=\"attachment_283\" aria-describedby=\"caption-attachment-283\" style=\"width: 190px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-283\" src=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_1.png\" alt=\"Screenshot of right-clicking on the Tables contextual menu in SQL Server 2014\" width=\"200\" height=\"177\" \/><\/a><figcaption id=\"caption-attachment-283\" class=\"wp-caption-text\">Right-clicking on &#8220;Tables&#8221; brings up the contextual menu. To create a new table, click &#8220;Table&#8230;&#8221;<\/figcaption><\/figure>\n<h2>The New Table in Design View<\/h2>\n<p>A new table will open in Design view. Add the columns, their data types, and column properties:<\/p>\n<figure id=\"attachment_282\" aria-describedby=\"caption-attachment-282\" style=\"width: 580px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-282 size-full\" src=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_2.png\" alt=\"Screenshot of table in Design view in SQL Server 2014.\" width=\"590\" height=\"584\" srcset=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_2.png 590w, https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_2-300x297.png 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><figcaption id=\"caption-attachment-282\" class=\"wp-caption-text\">A new table in Design view after some columns have been added. Clicking in a column name in the top pane will display its properties in the bottom pane. Modify these as required or leave them at the default values.<\/figcaption><\/figure>\n<h2>Save the Table<\/h2>\n<p>Save the table (either from the File menu, or by right-clicking on the table tab and selecting <kbd>Save Table_1<\/kbd>):<\/p>\n<figure id=\"attachment_284\" aria-describedby=\"caption-attachment-284\" style=\"width: 240px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-284\" src=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_3.png\" alt=\"Screenshot of right-clicking on the table tab in SQL Server 2014.\" width=\"250\" height=\"129\" \/><\/a><figcaption id=\"caption-attachment-284\" class=\"wp-caption-text\">Right-clicking on the table&#8217;s tab will present the &#8220;Save&#8230;&#8221; option.<\/figcaption><\/figure>\n<p>Name the table at the prompt and your table will be added to the database.<\/p>\n<h2>Check the New Table<\/h2>\n<p>It&#8217;s good practice\u00a0to check that the table has been created in the correct database and has all the correct columns and data types.<\/p>\n<p>You\u00a0will be able to see the new table\u00a0in the\u00a0Object Explorer.\u00a0If you can&#8217;t immediately see the new table in the Object Explorer, right click on <kbd>Tables<\/kbd> and click <kbd>Refresh<\/kbd>:<\/p>\n<figure id=\"attachment_285\" aria-describedby=\"caption-attachment-285\" style=\"width: 170px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-285\" src=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_5.png\" alt=\"Screenshot of refreshing the Object Explorer in SQL Server 2014.\" width=\"180\" height=\"163\" \/><\/a><figcaption id=\"caption-attachment-285\" class=\"wp-caption-text\">You may need to refresh the table list before you see the new table in the Object Explorer.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>When you can see the table in the Object Explorer, expand it to reveal all the columns and their respective data types:<\/p>\n<figure id=\"attachment_286\" aria-describedby=\"caption-attachment-286\" style=\"width: 190px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-286\" src=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_6.png\" alt=\"Screenshot of expanded table in the Object Explorer in SQL Server 2014.\" width=\"200\" height=\"377\" srcset=\"https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_6.png 200w, https:\/\/database.guide\/wp-content\/uploads\/2016\/05\/create_a_table_sql_server_2014_6-159x300.png 159w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/a><figcaption id=\"caption-attachment-286\" class=\"wp-caption-text\">Expanding a table in the Object Explorer displays the table&#8217;s columns.<\/figcaption><\/figure>\n<h2>Create a Table using a Query<\/h2>\n<p>You can also <a href=\"https:\/\/database.guide\/how-to-create-a-table-in-sql-server-using-a-query\/\">create a table using a query<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To create a table\u00a0in\u00a0SQL Server using the GUI: Ensuring that\u00a0the right database is expanded in Object Explorer,\u00a0right click on the Tables icon and select Table&#8230; from the contextual menu A new table will open in Design view. Add the columns, their data types, and column properties. Save the table (either from the File menu, or &#8230; <a title=\"How to Create a Table in SQL Server\" class=\"read-more\" href=\"https:\/\/database.guide\/how-to-create-a-table-in-sql-server\/\" aria-label=\"Read more about How to Create a Table in SQL Server\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[9,10,12],"class_list":["post-64","post","type-post","status-publish","format-standard","hentry","category-sql-server","tag-create-table","tag-how-to","tag-sql-server"],"_links":{"self":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/64","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/comments?post=64"}],"version-history":[{"count":10,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/64\/revisions"}],"predecessor-version":[{"id":732,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/posts\/64\/revisions\/732"}],"wp:attachment":[{"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/media?parent=64"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/categories?post=64"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/database.guide\/wp-json\/wp\/v2\/tags?post=64"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}