Table is a SQL Server object that is used to store related data or information. In table data is logically organized in rows and column format.
How to create table
Creating table by SQL Query:
Create table <<Table_Name>>
Create table Student
Before creating table you should know about datatype in SQL Server. So, to read about datatypes in SQL Server go to this link. Datatypes in SQL Server
We have created new table Student. And now we are going to insert data in Student table.
Syntex for inserting new record in SQL Server table is:
Insert into <<Table_Name>> (<<Column_Name1>>,<<Column_Name2>>,<<Column_Name3>>)
insert into Student (StudentID,Name,RollNo,ClassID) values (1,'Ramesh Kumar',1,10)
after executing this SQL Query we will receive message that how many rows are effected in table like (1 row(s)
Now we will look how we can retrieve or get inserting record from SQL Server table.
We will write a simple SQL Query to get all the records in table.
Select * from <<Table_Name>>
Select * from Student
Here we see all the data of student table. But if we want to see only specific information of all Student then we will write a SQL Query like
Select <<Column_Name1>>,<<Column_Name2>> from <<Table_Name>>
select StudentId, Name from Student
Finally we will see the result of above SQL Query.