<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/" >

<channel>
	<title>Tables &#8211; SQL Server Guides</title>
	<atom:link href="https://sqlserverguides.com/category/tables/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlserverguides.com</link>
	<description>Tutorials on SQL Server</description>
	<lastBuildDate>Sun, 05 Nov 2023 19:46:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>

<image>
	<url>https://sqlserverguides.com/wp-content/uploads/2023/10/sqlserverguides-150x150.png</url>
	<title>Tables &#8211; SQL Server Guides</title>
	<link>https://sqlserverguides.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Create Temporary Table in SQL Server Management Studio?</title>
		<link>https://sqlserverguides.com/create-temporary-table-in-sql-server-management-studio/</link>
		
		<dc:creator><![CDATA[Bijay Kumar Sahoo]]></dc:creator>
		<pubDate>Sat, 04 Nov 2023 12:00:00 +0000</pubDate>
				<category><![CDATA[Tables]]></category>
		<category><![CDATA[Create Temporary Table in SQL Server Management Studio]]></category>
		<guid isPermaLink="false">https://sqlserverguides.com/?p=16422</guid>

					<description><![CDATA[In this SQL Server tutorial, I will show you how to create temporary table in SQL Server Management Studio. First, you will understand &#8216;What is the temporary table?&#8217;, then you learn why a temporary table is created. After that, I will explain the types of temporary tables that you can create in SQL Server. Finally, ... <a title="How to Create Temporary Table in SQL Server Management Studio?" class="read-more" href="https://sqlserverguides.com/create-temporary-table-in-sql-server-management-studio/" aria-label="Read more about How to Create Temporary Table in SQL Server Management Studio?">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this SQL Server tutorial, I will show you how to create temporary table in SQL Server Management Studio.</p>



<p class="wp-block-paragraph">First, you will understand <strong>&#8216;What is the temporary table?&#8217;</strong>, then you learn <strong>why a temporary table is created</strong>.</p>



<p class="wp-block-paragraph">After that, I will explain the types of temporary tables that you can create in SQL Server. Finally, you will learn for example how to create local and global temporary tables. </p>



<p class="wp-block-paragraph">Also, you will know where the temporary table is stored on the SQL Server instance.</p>



<h2 class="wp-block-heading">Create Temporary Table in SQL Server Management Studio</h2>



<p class="wp-block-paragraph">Before proceeding to create temporary table in SQL Server Management Studio, you need to know <strong>&#8216;What is the temporary table?&#8217;</strong>.</p>



<p class="wp-block-paragraph">The temporary tables are like other tables in a database but they exist for a shorter time. A temporary or temp table is created based on the requirement and dropped or deleted when you are done using them.</p>



<p class="wp-block-paragraph">Consider a situation where you have data in big size and want to perform some calculations on that data. So instead of performing calculations on big original data, you create a temporary table containing that data to perform calculations.</p>



<p class="wp-block-paragraph">So in SQL Server, you can create temporary tables that exist until the database session. As soon as you end the database session, the temporary tables are deleted or dropped automatically.</p>



<p class="wp-block-paragraph">But why create temp tables, </p>



<ul class="wp-block-list">
<li>You create temp tables for storing intermediate results when performing complex queries.</li>



<li>Keep data in isolation to avoid interference with other users or sessions, for that you will create temporary tables.</li>



<li>If you need to access the same data or compute something again and again. Then you can create a temporary table for that to store the data or precomputed value to enhance the query performance.</li>



<li>If you have complex tasks, then you can break them down the complex task into manageable tasks by creating a temporary table for each smaller task. Then work on each temp table separately.</li>
</ul>



<p class="wp-block-paragraph">So you can manage the data by creating temporary tables within a session without affecting the original database tables.</p>



<p class="wp-block-paragraph">Now I hope you have a clear understanding of temporary tables in SQL Server, let&#8217;s move and learn about types of temporary tables.</p>



<p class="wp-block-paragraph">In SQL Server, there are two types of temporary tables:</p>



<ul class="wp-block-list">
<li>Local temporary tables: When you create this kind of temporary tables, you can access them within the current session and when the session ends, this temp table is deleted automatically. Only the user who creates the temp table can access it.</li>



<li>Global temporary tables: The global tables are created and accessed across different sessions. In other words, you create a global table and this table can be accessed by multiple users who have a separate session in the database. 
<ul class="wp-block-list">
<li>Same as the local temporary tables, the global temporary tables are also deleted whenever the database session ends.</li>
</ul>
</li>
</ul>



<p class="wp-block-paragraph">Let&#8217;s create both kinds of tables using the SQL Server Management Studio.</p>



<p class="wp-block-paragraph">So open the SSMS and connect to the SQL Server instance, if you haven&#8217;t installed it, then refer to the tutorial <a href="https://sqlserverguides.com/install-sql-server-management-studio/" target="_blank" rel="noreferrer noopener">Install SQL Server Management Studio</a>.</p>



<h3 class="wp-block-heading">Create Temporary Table in SQL Server Management Studio: Local Table</h3>



<p class="wp-block-paragraph">To create a local temporary table in SQL, follow the below syntax.</p>



<pre class="wp-block-code"><code>CREATE TABLE #tmpe_tablename(
column1 datatype1,
column2 datatype2,
...
);</code></pre>



<p class="wp-block-paragraph">Where,</p>



<ul class="wp-block-list">
<li><strong>CREAT TABLE:</strong> It is the command to create a new table.</li>



<li><strong>#temp_tablename:</strong> Name of the temporary table that you want to create. When specifying the name of a table always prefix the name with the single pound sign<strong>(#)</strong> to make that table a local temporary table.</li>



<li><strong>column1 datatype1:</strong> Define the columns and their data type of the temporary table.</li>
</ul>



<p class="wp-block-paragraph">Now use the above syntax to create a real table in SQL Server. So open the query editor by pressing the CTRL+N from your keyboard.</p>



<p class="wp-block-paragraph">After that write the below query to create a table named <strong>&#8216;Customer&#8217;</strong> which contains the customer information.</p>



<pre class="wp-block-code"><code>CREATE TABLE #Customer(
customer_id INT,
name VARCHAR(40),
country VARCHAR(60)
);</code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="991" height="487" src="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Local-Table.jpg" alt="Create Temporary Table in SQL Server Management Studio Local Table" class="wp-image-16425" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Local-Table.jpg 991w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Local-Table-300x147.jpg 300w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Local-Table-768x377.jpg 768w" sizes="(max-width: 991px) 100vw, 991px" /></figure>
</div>


<p class="wp-block-paragraph">When you execute the above query by clicking on the Execute button in the SSMS, the new local temporary <strong>Customer</strong> table is created with three columns <strong>customer_id</strong> of type INT, <strong>name</strong> of type VARCHAR(40), and <strong>country</strong> of type VARCHAR(60).</p>



<p class="wp-block-paragraph">Remember temporary tables in SQL Server are stored within the <strong>Temporary Tables</strong> of <strong>tempdb</strong> database of <strong>System Databases</strong> as shown in the below picture.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img decoding="async" width="442" height="636" src="https://sqlserverguides.com/wp-content/uploads/2023/10/View-Local-Temporary-Table-in-SQL-Server-Management-Studio.jpg" alt="View Local Temporary Table in SQL Server Management Studio" class="wp-image-16426" style="aspect-ratio:0.6949685534591195;width:334px;height:auto" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/View-Local-Temporary-Table-in-SQL-Server-Management-Studio.jpg 442w, https://sqlserverguides.com/wp-content/uploads/2023/10/View-Local-Temporary-Table-in-SQL-Server-Management-Studio-208x300.jpg 208w" sizes="(max-width: 442px) 100vw, 442px" /></figure>
</div>


<p class="wp-block-paragraph">Look at the above picture, the <strong>dbo.#Customer</strong> is your local temporary table that you have created.</p>



<p class="wp-block-paragraph">But as you know, temporary tables exist for a shorter time, or temporary table is deleted automatically whenever the database session ends. </p>



<p class="wp-block-paragraph">So end the database session by closing and starting SSMS, and then go to the same folder <strong>Temporary Tables</strong> to see the existence of the local temporary Customer table.</p>



<p class="wp-block-paragraph">As soon as you end the database session, you won&#8217;t see the local temporary tables.</p>



<h3 class="wp-block-heading">Create Temporary Table in SQL Server Management Studio: Global Table</h3>



<p class="wp-block-paragraph">To create a global temporary table in SQL, follow the below syntax.</p>



<pre class="wp-block-code"><code>CREATE TABLE ##tmpe_tablename(
column1 datatype1,
column2 datatype2,
...
);</code></pre>



<p class="wp-block-paragraph">Where,</p>



<ul class="wp-block-list">
<li><strong>CREAT TABLE:</strong> It is the command to create a new table.</li>



<li><strong>##temp_tablename:</strong> Name of the global temporary table that you want to create. When specifying the name of a table always prefix the name with the double pound sign<strong>(##)</strong> to make that table a global temporary table.</li>



<li><strong>column1 datatype1:</strong> Define the columns and their data type of the temporary table.</li>
</ul>



<p class="wp-block-paragraph">Now write the below query to create a global temporary <strong>Product</strong> table.</p>



<pre class="wp-block-code"><code>CREATE TABLE ##Product(
product_id INT,
product_name VARCHAR(40),
product_description VARCHAR(60)
);</code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="950" height="570" src="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Global-Table.jpg" alt="Create Temporary Table in SQL Server Management Studio Global Table" class="wp-image-16429" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Global-Table.jpg 950w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Global-Table-300x180.jpg 300w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Temporary-Table-in-SQL-Server-Management-Studio-Global-Table-768x461.jpg 768w" sizes="(max-width: 950px) 100vw, 950px" /></figure>
</div>


<p class="wp-block-paragraph">When you execute the above query by clicking on the Execute button in the SSMS, the new global temporary <strong>Product</strong> table is created with three columns <strong>product_id</strong> of type INT, <strong>product_name</strong> of type VARCHAR(40), and <strong>product_description</strong> of type VARCHAR(60).</p>



<p class="wp-block-paragraph">Now to check the global temporary table, go to the <strong>Temporary Tables</strong> folder of the <strong>tempdb</strong> database as shown in the below picture.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="455" height="608" src="https://sqlserverguides.com/wp-content/uploads/2023/10/View-Global-Temporary-Table-in-SQL-Server-Management-Studio.jpg" alt="View Global Temporary Table in SQL Server Management Studio" class="wp-image-16431" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/View-Global-Temporary-Table-in-SQL-Server-Management-Studio.jpg 455w, https://sqlserverguides.com/wp-content/uploads/2023/10/View-Global-Temporary-Table-in-SQL-Server-Management-Studio-225x300.jpg 225w" sizes="(max-width: 455px) 100vw, 455px" /></figure>
</div>


<p class="wp-block-paragraph">When you visit the <strong>Temporary Tables</strong> folder, you see the global temporary <strong>dbo.##Product</strong> table as shown in the above picture.</p>



<p class="wp-block-paragraph">If you go to the same <strong>Temporary Tables</strong> with different sessions, you will see the same global temporary table.</p>



<p class="wp-block-paragraph">Now again close the SSMS and come back to check the existence of the global temporary table. If you don&#8217;t see the global temporary table, it means it is deleted as the current database session ends.</p>



<p class="wp-block-paragraph">This is how to create temporary table in SQL Server Management Studio using the single <strong>pound(#)</strong> and <strong>double pound(##)</strong> with the <strong>CREATE TABLE</strong> statement to create a local and global temporary table.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">In this SQL Server tutorial, you learned how to <strong>create a temporary table in SQL Server</strong>. You learned about two types of temporary tables, local and global temporary tables. Also, you learned why to create a temporary table.</p>



<p class="wp-block-paragraph">You may like to read the following tutorials:</p>



<ul class="wp-block-list">
<li><a href="https://sqlserverguides.com/create-database-if-not-exists-in-sql-server/">Create Database If Not Exists in SQL Server</a></li>



<li><a href="https://sqlserverguides.com/find-database-owner-in-sql-server/">How To Find Database Owner in SQL Server?</a></li>
</ul>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img alt='Bijay Kumar Sahoo' src='https://secure.gravatar.com/avatar/18a79d27129a98c6530098c50aef09aa901fced58315025237441af82a0fa179?s=100&#038;d=mm&#038;r=g' srcset='https://secure.gravatar.com/avatar/18a79d27129a98c6530098c50aef09aa901fced58315025237441af82a0fa179?s=200&#038;d=mm&#038;r=g 2x' class='avatar avatar-100 photo' height='100' width='100' itemprop="image"/></div><div class="saboxplugin-authorname"><a href="https://sqlserverguides.com/author/fewlines4biju/" class="vcard author" rel="author"><span class="fn">Bijay Kumar Sahoo</span></a></div><div class="saboxplugin-desc"><div itemprop="description"><p>After working for more than 15 years in the Software field, especially in Microsoft technologies, I have decided to share my expert knowledge of SQL Server. Check out all the SQL Server and related database tutorials I have shared here. Most of the readers are from countries like the United States of America, the United Kingdom, New Zealand, Australia, Canada, etc. I am also a <a href="https://mvp.microsoft.com/en-us/PublicProfile/5000972" rel="noopener" target="_blank">Microsoft MVP</a>. Check out more <a href="https://sqlserverguides.com/about/" rel="noopener">here</a>.</p>
</div></div><div class="saboxplugin-web "><a href="https://sqlserverguides.com" target="_self">sqlserverguides.com</a></div><div class="clearfix"></div><div class="saboxplugin-socials "><a title="Facebook" target="_self" href="https://www.facebook.com/fewlines4biju" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-facebook" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 264 512"><path fill="currentColor" d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"></path></svg></span></a><a title="Linkedin" target="_self" href="https://www.linkedin.com/in/fewlines4biju/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-linkedin" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 448 512"><path fill="currentColor" d="M100.3 480H7.4V180.9h92.9V480zM53.8 140.1C24.1 140.1 0 115.5 0 85.8 0 56.1 24.1 32 53.8 32c29.7 0 53.8 24.1 53.8 53.8 0 29.7-24.1 54.3-53.8 54.3zM448 480h-92.7V334.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V480h-92.8V180.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V480z"></path></svg></span></a><a title="Twitter" target="_self" href="https://twitter.com/fewlines4biju" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Pinterest" target="_self" href="https://in.pinterest.com/fewlines4biju/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-pinterest" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 496 512"><path fill="currentColor" d="M496 256c0 137-111 248-248 248-25.6 0-50.2-3.9-73.4-11.1 10.1-16.5 25.2-43.5 30.8-65 3-11.6 15.4-59 15.4-59 8.1 15.4 31.7 28.5 56.8 28.5 74.8 0 128.7-68.8 128.7-154.3 0-81.9-66.9-143.2-152.9-143.2-107 0-163.9 71.8-163.9 150.1 0 36.4 19.4 81.7 50.3 96.1 4.7 2.2 7.2 1.2 8.3-3.3.8-3.4 5-20.3 6.9-28.1.6-2.5.3-4.7-1.7-7.1-10.1-12.5-18.3-35.3-18.3-56.6 0-54.7 41.4-107.6 112-107.6 60.9 0 103.6 41.5 103.6 100.9 0 67.1-33.9 113.6-78 113.6-24.3 0-42.6-20.1-36.7-44.8 7-29.5 20.5-61.3 20.5-82.6 0-19-10.2-34.9-31.4-34.9-24.9 0-44.9 25.7-44.9 60.2 0 22 7.4 36.8 7.4 36.8s-24.5 103.8-29 123.2c-5 21.4-3 51.6-.9 71.2C65.4 450.9 0 361.1 0 256 0 119 111 8 248 8s248 111 248 248z"></path></svg></span></a></div></div></div>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Create a Table in SQL Server Management Studio Using Query?</title>
		<link>https://sqlserverguides.com/create-a-table-in-sql-server-management-studio-using-query/</link>
		
		<dc:creator><![CDATA[Bijay Kumar Sahoo]]></dc:creator>
		<pubDate>Mon, 30 Oct 2023 12:00:00 +0000</pubDate>
				<category><![CDATA[Tables]]></category>
		<category><![CDATA[Create a Table in SQL Server Management Studio Using Query]]></category>
		<guid isPermaLink="false">https://sqlserverguides.com/?p=16330</guid>

					<description><![CDATA[In this SQL Server tutorial, you will learn how to create a table in SQL Server Management Studio using query. You will understand the concept of a table in SQL Server and then understand how to open the query editor in SQL Server Management Studio, where you can run the query. After that, you will ... <a title="How to Create a Table in SQL Server Management Studio Using Query?" class="read-more" href="https://sqlserverguides.com/create-a-table-in-sql-server-management-studio-using-query/" aria-label="Read more about How to Create a Table in SQL Server Management Studio Using Query?">Read more</a>]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">In this SQL Server tutorial, you will learn how to <strong>create a table in SQL Server Management Studio using query</strong>.</p>



<p class="wp-block-paragraph">You will understand the concept of a table in SQL Server and then understand how to open the query editor in <a href="https://sqlserverguides.com/install-sql-server-management-studio/" data-type="link" data-id="https://sqlserverguides.com/install-sql-server-management-studio/">SQL Server Management Studio</a>, where you can run the query.</p>



<p class="wp-block-paragraph">After that, you will understand table syntax, and you will later create a table. Finally, you will create a table and view the created table in SSMS.</p>



<h2 class="wp-block-heading">Create Table in SQL Server Management Studio Using Query</h2>



<p class="wp-block-paragraph">Before you learn how to create a table in SQL Server Management Studio using query, you must understand <strong>&#8216;What is a table in SQL Server?&#8217;</strong>.</p>



<p class="wp-block-paragraph">If you have used the excel, then you probably know the <strong>spreadsheets</strong>. A table is like a spreadsheet that stores information in an organized way, such as storing information <strong>in rows and columns</strong>.</p>



<p class="wp-block-paragraph">In other words, the table consists of rows and columns. <strong>The row of the table represents the record or piece of data and the column in the table represents the attribute of that data.</strong></p>



<p class="wp-block-paragraph">Now you know about <strong>tables in SQL Server</strong>, let&#8217;s understand how to create them using the query in SSMS.</p>



<p class="wp-block-paragraph">Open the SSMS and connect to the SQL Server instance, after connecting, press <strong>CTRL + N</strong> to open the <strong>Query Editor</strong> as shown below.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="410" src="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Opening-SSMS-1024x410.jpg" alt="Create Table in SQL Server Management Studio Using Query Opening SSMS" class="wp-image-16334" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Opening-SSMS-1024x410.jpg 1024w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Opening-SSMS-300x120.jpg 300w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Opening-SSMS-768x308.jpg 768w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Opening-SSMS.jpg 1275w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p class="wp-block-paragraph">To create a table in SQL Server using query follow the below syntax.</p>



<pre class="wp-block-code"><code>CREATE TABLE table_name (
column_name1 datatype1 constraint,
column_name2 datatype2 constraint,
...
);</code></pre>



<p class="wp-block-paragraph">Where,</p>



<ul class="wp-block-list">
<li><strong>CREATE TABLE:</strong> It is a command in SQL Server to create a table.</li>



<li><strong>table_name:</strong> It is the name of a new table that you want to create.</li>



<li><strong>column_name1, column_nam2:</strong> The columns of the table that represent the attribute.</li>



<li><strong>datatype1, datatype2:</strong> The data types for each column in a table. These data types define what kind of data each column is going to store such as integer, varchar, etc.</li>



<li><strong>constraint:</strong> You can also specify constraints on each column such as PRIMARY KEY, NOT NULL, FOREIGN KEY, etc.</li>
</ul>



<p class="wp-block-paragraph">Using the above syntax you can create a table in SQL Server. </p>



<p class="wp-block-paragraph">For example, you have access to the retail business database and are given a task to create a table that should store the customer information. </p>



<p class="wp-block-paragraph">So create a table named <strong>Customers</strong> with columns <strong>CustomerID</strong>, <strong>CustomerName</strong>, <strong>Email</strong>, and <strong>Phone</strong> as shown below.</p>



<pre class="wp-block-code"><code>CREATE TABLE Customers(
CustomerID INT PRIMARY KEY,
CustomerName VARCHAR(40),
Email VARCHAR(60),
Phone VARCHAR(15)
);</code></pre>



<p class="wp-block-paragraph">In the above query, define a table <strong>Customers</strong> with columns <strong>CustomerID</strong> of type <strong>INT</strong>, <strong>CustomerName</strong>, <strong>Email</strong>, and <strong>Phone</strong> of type <strong>VARCHAR</strong>. Also, CustomerID is the <strong>PRIMARY KEY</strong> column so that each customer can have unique values.</p>



<p class="wp-block-paragraph">Write the above in the query editor, as shown below.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="348" src="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Define-Table-1024x348.jpg" alt="" class="wp-image-16337" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Define-Table-1024x348.jpg 1024w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Define-Table-300x102.jpg 300w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Define-Table-768x261.jpg 768w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Define-Table.jpg 1273w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p class="wp-block-paragraph">To execute the query, which will create a table of <strong>Customers</strong>, click on the Execute button as shown in the below picture.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="531" src="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Execution-1024x531.jpg" alt="Create Table in SQL Server Management Studio Using Query Execution" class="wp-image-16339" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Execution-1024x531.jpg 1024w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Execution-300x155.jpg 300w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Execution-768x398.jpg 768w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Using-Query-Execution.jpg 1235w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p class="wp-block-paragraph">At the bottom of the query editor, you can see the message &#8216;Commands completed successfully&#8217; which means table <strong>Customers</strong> is created successfully.</p>



<p class="wp-block-paragraph">To view the created table, expand the <strong>Databases</strong> node from the <strong>Object Explorer</strong> area. Then, expand the <strong>System Databases,</strong> which contain all the system databases on the SQL Server.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="549" src="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Viewing-Created-Table-1024x549.jpg" alt="Create Table in SQL Server Management Studio Viewing Created Table" class="wp-image-16340" style="aspect-ratio:1.8652094717668488;width:735px;height:auto" srcset="https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Viewing-Created-Table-1024x549.jpg 1024w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Viewing-Created-Table-300x161.jpg 300w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Viewing-Created-Table-768x412.jpg 768w, https://sqlserverguides.com/wp-content/uploads/2023/10/Create-Table-in-SQL-Server-Management-Studio-Viewing-Created-Table.jpg 1225w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p class="wp-block-paragraph">After that, within the System Databases, there are different databases related to the system, so expand the master database, and then, within the master database, expand the folder <strong>Tables</strong>.</p>



<p class="wp-block-paragraph">Under the <strong>Tables</strong> folder, <strong>dbo.Customers</strong> is the table that you have created, as you can see in the above picture. Remember, by default, the table that you create is always stored in the master database of System Databases in SQL Server.</p>



<p class="wp-block-paragraph">You can also view the table constraints, keys, and indexes by expanding the folders <strong>Constraints</strong>, Keys, and <strong>Indexes</strong> of Tables. This is how you can create a table in SQL Server Management Studio using query.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p class="wp-block-paragraph">In this SQL Server tutorial, you learned <strong>how to create a table in SSMS using query</strong>. Then, we discussed the concept of a table. After that, you learned about the table syntax. In the end, you created a table for Customers and viewed the table under the Databases node in the SQL Server.</p>



<p class="wp-block-paragraph">You may also like:</p>



<ul class="wp-block-list">
<li><a href="https://sqlserverguides.com/create-database-if-not-exists-in-sql-server/">How to Create Database If Not Exists in SQL Server?</a></li>



<li><a href="https://sqlserverguides.com/find-database-owner-in-sql-server/">How To Find Database Owner in SQL Server?</a></li>



<li><a href="https://sqlserverguides.com/create-temporary-table-in-sql-server-management-studio/">How to Create Temporary Table in SQL Server Management Studio?</a></li>
</ul>
<div class="saboxplugin-wrap" itemtype="http://schema.org/Person" itemscope itemprop="author"><div class="saboxplugin-tab"><div class="saboxplugin-gravatar"><img alt='Bijay Kumar Sahoo' src='https://secure.gravatar.com/avatar/18a79d27129a98c6530098c50aef09aa901fced58315025237441af82a0fa179?s=100&#038;d=mm&#038;r=g' srcset='https://secure.gravatar.com/avatar/18a79d27129a98c6530098c50aef09aa901fced58315025237441af82a0fa179?s=200&#038;d=mm&#038;r=g 2x' class='avatar avatar-100 photo' height='100' width='100' itemprop="image"/></div><div class="saboxplugin-authorname"><a href="https://sqlserverguides.com/author/fewlines4biju/" class="vcard author" rel="author"><span class="fn">Bijay Kumar Sahoo</span></a></div><div class="saboxplugin-desc"><div itemprop="description"><p>After working for more than 15 years in the Software field, especially in Microsoft technologies, I have decided to share my expert knowledge of SQL Server. Check out all the SQL Server and related database tutorials I have shared here. Most of the readers are from countries like the United States of America, the United Kingdom, New Zealand, Australia, Canada, etc. I am also a <a href="https://mvp.microsoft.com/en-us/PublicProfile/5000972" rel="noopener" target="_blank">Microsoft MVP</a>. Check out more <a href="https://sqlserverguides.com/about/" rel="noopener">here</a>.</p>
</div></div><div class="saboxplugin-web "><a href="https://sqlserverguides.com" target="_self">sqlserverguides.com</a></div><div class="clearfix"></div><div class="saboxplugin-socials "><a title="Facebook" target="_self" href="https://www.facebook.com/fewlines4biju" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-facebook" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 264 512"><path fill="currentColor" d="M76.7 512V283H0v-91h76.7v-71.7C76.7 42.4 124.3 0 193.8 0c33.3 0 61.9 2.5 70.2 3.6V85h-48.2c-37.8 0-45.1 18-45.1 44.3V192H256l-11.7 91h-73.6v229"></path></svg></span></a><a title="Linkedin" target="_self" href="https://www.linkedin.com/in/fewlines4biju/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-linkedin" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 448 512"><path fill="currentColor" d="M100.3 480H7.4V180.9h92.9V480zM53.8 140.1C24.1 140.1 0 115.5 0 85.8 0 56.1 24.1 32 53.8 32c29.7 0 53.8 24.1 53.8 53.8 0 29.7-24.1 54.3-53.8 54.3zM448 480h-92.7V334.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V480h-92.8V180.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V480z"></path></svg></span></a><a title="Twitter" target="_self" href="https://twitter.com/fewlines4biju" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-twitter" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 30 30"><path d="M26.37,26l-8.795-12.822l0.015,0.012L25.52,4h-2.65l-6.46,7.48L11.28,4H4.33l8.211,11.971L12.54,15.97L3.88,26h2.65 l7.182-8.322L19.42,26H26.37z M10.23,6l12.34,18h-2.1L8.12,6H10.23z" /></svg></span></a><a title="Pinterest" target="_self" href="https://in.pinterest.com/fewlines4biju/" rel="nofollow noopener" class="saboxplugin-icon-grey"><svg aria-hidden="true" class="sab-pinterest" role="img" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 496 512"><path fill="currentColor" d="M496 256c0 137-111 248-248 248-25.6 0-50.2-3.9-73.4-11.1 10.1-16.5 25.2-43.5 30.8-65 3-11.6 15.4-59 15.4-59 8.1 15.4 31.7 28.5 56.8 28.5 74.8 0 128.7-68.8 128.7-154.3 0-81.9-66.9-143.2-152.9-143.2-107 0-163.9 71.8-163.9 150.1 0 36.4 19.4 81.7 50.3 96.1 4.7 2.2 7.2 1.2 8.3-3.3.8-3.4 5-20.3 6.9-28.1.6-2.5.3-4.7-1.7-7.1-10.1-12.5-18.3-35.3-18.3-56.6 0-54.7 41.4-107.6 112-107.6 60.9 0 103.6 41.5 103.6 100.9 0 67.1-33.9 113.6-78 113.6-24.3 0-42.6-20.1-36.7-44.8 7-29.5 20.5-61.3 20.5-82.6 0-19-10.2-34.9-31.4-34.9-24.9 0-44.9 25.7-44.9 60.2 0 22 7.4 36.8 7.4 36.8s-24.5 103.8-29 123.2c-5 21.4-3 51.6-.9 71.2C65.4 450.9 0 361.1 0 256 0 119 111 8 248 8s248 111 248 248z"></path></svg></span></a></div></div></div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: sqlserverguides.com @ 2026-09-06 23:16:53 by W3 Total Cache
-->