SQL Server Create Table

How to build an SQL Server Create Table query? This basic example creates a Sales table. It is using different data types, such as strings, numeric values, decimal values, integers and Boolean.

 

This SQL Server example is easy to customize. Just copy and paste it to your computer, inside your SQL code editor (like SQL Server Management Studio), and execute it!  Indeed it’s easy to have the exact syntax by doing a copy paste.

 

SQL Server Create Table

This simple SQL Server query creates a Sales table to store data. Indeed the dbo.SALES table can store for example the month name, the current month, the employee number, the number of sales and their respective amounts. 

CREATE TABLE [dbo].[SALES] 
(
 [MonthName] NVARCHAR(50), 		-- alphanumeric
 [MonthCurrentt]  	BIT, 		-- Boolean, 0 or 1 , false / true
 [NumberMonth] 		TINYINT, 	-- very small integer, from 0 to 255
 [EmployeeNumber] 	SMALLINT, 	-- small integer, minimum -2^15, maximum 2^15
 [NumberOfClients] 	INTEGER, 	-- integer, minimum -2^31, maximum 2^31
 [NumberOfSales] 	BIGINT, 	-- big integer, minimum: -2^63, maximum 2^63
 [Amount_ET] 		NUMERIC(15,5), 	-- numeric, 15 digits, with 5 after the comma 
 [Amount_IT] 		DECIMAL(15,5) 	-- decimal, 15 digits, with 5 after the comma
);

-- Note: 
-- Amount_ET stands for Amount Excluding Taxes
-- Amount_IT stands for Amount Including Taxes

 

 

Be the first to comment

Leave a Reply