Sunday, January 14, 2018

How To Insert Data In Mssql

Hello Friend Today In This Blog I Will Show You How To Create Insert Data In Mssql.The INSERT statement in SQL Server is versatile. It now allows the insertion of multiple rows of literal values. It also provides the output clause that solves a number of common problems such as ascertaining the value of identity fields, and other calculated fields in tables, or for auditing the rows that are added to tables.

The INSERT statement lets you add one or more rows to a table or view in a SQL Server database. The statement is one of the primary data modification language (DML) statements available in Transact-SQL, along with UPDATE, MERGE, and DELETE. You can use the INSERT statement to add data that you specifically define, or you can add data that you retrieve from other tables or views. You can also include an OUTPUT clause in your INSERT statement to capture the statement’s results for auditing or verification purposes.

In this article, I explain how to use the INSERT statement to add data to SQL Server tables. The examples I show are based on the AdventureWorks2008 sample database, installed on a local instance of SQL Server 2008. However, you can run most of these examples against the AdventureWorks database in SQL Server 2005, with minor modifications, such as changing the database name. Where appropriate, I note which features are not supported in 2005.

Insert Command

There are multiple ways to insert the data into the database:
1)Insert data into a Table
2)Insert data in selected columns
3)Insert using select statement

4)Insert in Multiple rows or tables

INSERT INTO Syntax


INSERT INTO table_name (column1, column2, column3, ...)

VALUES (value1, value2, value3, ...);


OR


INSERT INTO table_name

VALUES (value1, value2, value3, ...);

Here Is An Example Related To Topic

Step 1 :Create database

Create database MacPro




Step 2:Create table

Here In This step We Will Create table.

Here In This Step We Required Four Column With Name ids ,iname ,ilocation and iprice using Parameter bigint,varchar and float.


create table item
(
ids bigint,
iname varchar(50),
ilocation varchar(50),
iprice float
);



Step 3 :Create Insert Trigger Functionality

Here In This Step We Will Insert Data Using Insert Command.
Data Will Be Added Manually Using Insert Command.

Insert Into item values(1,'PC','LA',10.2)

Insert Into item (ids,iname,ilocation,iprice)  values (2,'MOUSE','DC',110.2)




select *from item





Here Is The  Video Related To Topic


No comments:

Post a Comment