Saturday, May 3, 2025

Create Table

 In SQL server, table can be created by two ways:
- using graphical interface

- using query


Using GUI

- Go to the Database, expand it, you will see folder named Tables.

- Right Click on the Tables and then click Table



- Now provide Name of columns and its data type and then save it.


Using query 


Here, we are trying to make column Id as IDENTITY (we will discuss it later).  IDENTITY (1,1), is Seed and Increment, written which means it will start from 1 and incremented by 1. i.e. we don't have to insert any value in that column. it will automatically start from 1 and then increases as 2, 3, 4,.....

NULL means it allows null value (okay if no value if provided) while NOT NULL means we have to provide some value.

After writing this query we can run it (or press F5). then a message will be seen as shown below:


This means our code executed.

Now table is created inside Tables Folder. Right click on the folder and click Refresh. You should be able to see it there.




EmoticonEmoticon

Create Table in Sql using Select Statement

In SQL Server, one can create a table using SELECT statement. Let's learn how we do it. Let's take a scenario where you are ordering...