This article will show you how you can create or perform insert,
update and delete, select, drop and create table operation in an sql server
database.
Some of my previous articles are as follows: Bind
and Validate GridView TextBox Value by jQuery In Asp.Net Using C#, Asp.Net
Login Form With User Role Selection By Dropdownlist In Asp.net Using C#.Net,
Populate
Data in GridView on DropdownList Selected Role in Asp.net Using C#.net, Add
Select text in Dropdownlist in Asp.Net OR Adding Default Select Option in the
DropDownList Using C#.Net in Asp.Net, Search
and Display Data In GridView From Database Table In Asp.Net Using C#.Net, How
to Bind Data to Webgrid in ASP.net MVC Using C#.Net.
So for this article first we will create a table in sql server database.
So for this article first we will create a table in sql server database.
Now we will create the template for the insert, update and delete query. For creating query check the path.
Go to Table -> Right click on table -> Script Table As
After this you will get below mention menu for Select,
Insert, Update and delete. Now select one of the option and generate the query
for that table.
CREATE:
CREATE:
CREATE TABLE [dbo].[UserDetail](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) NULL,
[Address]
[varchar](100)
NULL,
[UserType]
[varchar](50)
NULL,
[Earning] [int] NULL,
CONSTRAINT [PK_UserDetail] PRIMARY
KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS
= ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON
[PRIMARY]
|
INSERT:
INSERT INTO [dbo].[UserDetail]
([Name]
,[Address]
,[UserType]
,[Earning])
VALUES
(<Name, varchar(50),>
,<Address, varchar(100),>
,<UserType, varchar(50),>
,<Earning, int,>)
GO
|
UPDATE:
UPDATE [dbo].[UserDetail]
SET [Name] = <Name, varchar(50),>
,[Address] = <Address, varchar(100),>
,[UserType] = <UserType, varchar(50),>
,[Earning] = <Earning, int,>
WHERE <Search
Conditions,,>
GO
|
DELETE:
DELETE FROM [dbo].[UserDetail]
WHERE <Search
Conditions,,>
GO
|
SELECT:
SELECT [Id]
,[Name]
,[Address]
,[UserType]
,[Earning]
FROM [dbo].[UserDetail]
GO
|
DROP:
IF
EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserDetail]')
AND type in (N'U'))
DROP TABLE [dbo].[UserDetail]
GO
|
0 comments:
Please let me know your view