Sql Tutorial Class


How to insert values in particular column in sql


How to insert values in particular column in sql.


How to insert values in particular column in sql: INSERT INTO Sql Statement is used to insert values ​​in particular columns. After completing the creation of the table, the user needs to store data ​​in the table. To store the values ​​in a table on the SQL server, the user must specify the number of columns and values. When inserting values ​​into the table on the sql server, the column number and the number of inserted values ​​must match. As if a table created with 10 columns / fields, then 10 values ​​must be inserted, not less or more values. Inserting values ​​in the table in the SQL database is very easy. To insert values ​​into the table in SQL Server, follow the instructions.

 How to insert into values in particular column in sql. 

[Note: To create table in sql server database Click here..)

Syntax:
           Insert Into TABLE_NAME Values(value1, value2, value3, value4...)
                            OR
           Insert into TABLE_NAME (Column_Name, Column_Name2, Column_Name3, Column_Name4...) Values (Value1, Value2,Value3, Value4...)

Description:
                 Insert Into: Insert Into is a sql statement which is sued to insert value into table.
                 TABLE_NAME: It is user define name of table. Like StudentDetails, Employee etc.
                 Values: Value is a sql statement which is used with Insert Into in sql statement.

Table in Sql Server (Note: If table has not created then create table before 

Create Table ItemDetails
(
ItemCode int,
ItemName varchar(30),
ManufactureCompany varchar(50),
ItemSearialNo varchar(30),
ItemCategory varchar(30),
ItemQuantity int,
ItemPrice float,
ProductCountry varchar(30)
)

Insert into ItemDetails values('1','Samsung Mobile','Samsung','S12345','Mobile','500','240','Korea')

Insert into ItemDetails values('2','Samsung Pro','Samsung','SP1234','Mobile','100','300','Korea')

Insert into ItemDetails values('3','Samsung Headphone','Samsung','SH2345','Headphone','50','50','Korea')

Insert into ItemDetails values('4','iPhone','iPone','iP12345','Mobile','1000','500','United Stat')

Insert into ItemDetails values('5','Apple Mobile','Apple','A12345','Mobile','200','300','United Stat')

Insert into ItemDetails values('6','Apple Computer','Apple','A12343','Computer','200','400','United Stat')

Insert into ItemDetails values('7','Apple Macbook','Apple','AM2345','Macbook','50','600','United Stat')

Insert into ItemDetails values('8','Dell Computer','DELL','D02345','Computer','200','240','United Stat')

Insert into ItemDetails values('9','Dell Laptop','DELL','DL2345','Laptop','30','240','United Stat')

Insert into ItemDetails values('10','Apple Laptop','Apple','AL2345','Laptop','500','100','United Stat')



Second Method
Insert into ItemDetails (ItemCode,ItemName,ManufactureCompany,ItemSearialNo,ItemCategory,ItemQuantity,ItemPrice,ProductCountry) 
values('17','Ascer Printer','Ascer','AP2345','Printer','200','150','China')



Insert into ItemDetails (ItemCode,ItemName,ManufactureCompany,ItemSearialNo,ItemCategory,ItemQuantity,ItemPrice,ProductCountry) 
values('18','Brother Photocopy','Brother','BP2345','Printer','20','150','China')




Inserting values into table in sql server. Example in Image

How to insert into table in sql server





No comments:

Post a Comment