Introduction:

Here we will learn what is a table and how to create a table in SQL Server and we explain how to create primary key with identity column. Insert a record in SQL server table using insert statement and select a table to retrieve all record from the table with example.

Description:

Sql server support several types of objects that can be create within a sql database. SQL Server stores and manages data in its primary data structures, tables a table consist row and columns with data stored at the intersections of these rows and columns. As an example, the Adventure Works Human Resources. Student table is shown in the table, each row is associated with columns and each column has certain restrictions placed on its content. These restrictions comprise the data domain. The data domain defines all the values a column can contain. At the lowest level, the data domain is based on the data type of the column. For instance, a small int column can contain any integer values between −32,768 and +32,767. The data domain of a column can be further constrained through the use of check constraints, triggers, and foreign key constraints. Check constraints provide a means of automatically checking that the value of a column is within a certain range or equal to a certain value whenever a row is inserted or updatedTriggers can provide similar functionality to check constraints. Foreign key constraints allow you to declare a relationship between the columns of one table and the columns of another table. You can use foreign key constraints to restrict the data domain of a column to only include those values that appear in a designated column of another table. SQL Server also have Temporary Tables. Temporary tables are stored in tempdb. There are two types of temporary tables: local and global. System Tables. SQL Server stores the data that defines the configuration of the server and all its tables in a special set of tables known as system tables.

 

here we are going to create  a table in SQL Srver.

 


CREATE TABLE STUDENT

(

StudentID int primary key identity(1,1),

StudentName nvarchar(100),

StudentAge int

)



 Here we are going to insert a record in student table shown below

Insert into STUDENT(StudentName,StudentAge)
         values('Aditya',25)


Here we are going to retrieve all record from student using select statement

SELECT * FROM STUDENT


Result:





I hope this Article will help to you.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like