Friday 4 August 2017

How to create table in SQL server?

How to Create table in SQL Server ?
After long time i come back on Blogger due to some busy schedule , i was not able to write blogs on ASP.Net  since  last 5 months. Now here on demand of students ,trainee and some beginner level developers , they sent me few emails and request to write blogs on CRUD  operations in ASP.Net with two tier architecture and three tier architecture , this is my first post after a long Interval.

Firstly i would like to define what is CRUD Operations?
CRUD stands for Create , Read , Update and Delete operations inASP.net , so we need a database for storing the records . so our first step is to create a database , and a table for storing the records in it.

We are using SQL Server 2008 R2 as database and visual studio 2015 for IDE .

Step 1 :- Create a database and table into SQL Server.
Step 2 :- Design a ASP.Net  Web forms to SAVE Data.

Open the SQL server Management Studio like the process given below.

After Clicking on the Icon presented on the above screen . SQL Server Management tools will open shown in below Image.



 On the Above Image , Choose server Type as DataBase Engine
Server Name : it is the name of database server where our data will store , on the above pic PC is the name of Database server because we are using Local Host or local system so our Computer name will be the server name , you can also used the
(local) or . (dot) for Server name for local host.
Authentication means which type of authentication you are using like SQL Server Authentication
or windows authentication.
we are using windows authentication for local , so we don't need user name and password to write here.
If you are using a Database server with IP address then following will be the process for creating the database.
In SQL Server Authentication mode we need Login UserName and Password as shown in below figure
Click on Connect Button and Sql Server will open as shown in below fig.
Write Click on database and select add new DataBAse.


Example is the Database Name and click Ok......


Write click on tables and select New table.


Write the column names and choose the datatypes for columns and make the RegistrationID as a primary key for right click and set as primary key.




Save the table as StudentRegistration_tbl.
we can also create the table with query given below.

CREATE TABLE StduentRegistration_tbl
(
RegistrationID int IDENTITY(1,1) NOT NULL,
FirstName  nvarchar(max) NOT NULL,
LastName nvarchar(max) NOT NULL,
UserName nvarchar(max) NOT NULL,
Password nvarchar(max) NOT NULL,
EmailID nvarchar(max) NULL,
MobileNumber nvarchar(50) NOT NULL,
DOB datetime NULL,
GenderID  int  NOT NULL,
 CONSTRAINT [PK_StduentRegistration_tbl] PRIMARY KEY CLUSTERED 
(
[RegistrationID] ASC
)
) ON [PRIMARY]









No comments:

Post a Comment

Creating First WEB API Project from scratch ?

  For creating Web API project open your Visual Studio Editor and Create New Project as shown in below figure. Now you have to select  ASP.N...