Version: SQL Server 2019
Here I’ll quickly overview the syntax of how to create a simple table on an MSSQL server database.
It’s quite straightforward the table creation, for it, we only have the necessity of using Create Table statement. Afterward, set the columns we aim for and their related types. We may consider, as well, if we want that the columns allow null values or not and establish which column(s) will be part of the primary key.
Please check this example:
CREATE TABLE customer
(
CustomerNo INTEGER NOT NULL CONSTRAINT prim_cust PRIMARY KEY,
CustomerFirstName NVARCHAR(20) NOT NULL,
CustomerLastName NVARCHAR(20) NOT NULL,
CountryCode NVARCHAR(20)
)
The execution of the above code should result in a table structure as the following one…
This is a simple sample of how you can create a table… So, put it into action… Go ahead and try it by yourself and check the results.
With these simple samples, we’ll start to build a model database that I intend to use and share some useful concepts, tips and tricks. Stay tuned!
Top comments (0)