HomeХобби и стильRelated VideosMore From: Internet Services and Social Networks Tutorials from HowTech

How to Insert Into Table In SQL

117 ratings | 73733 views
Follow this step by step easy tutorial to learn how to insert data into the tables in SQL Server Database via queries. Don't forget to check out our site http://howtech.tv/ for more free how-to videos! http://youtube.com/ithowtovids - our feed http://www.facebook.com/howtechtv - join us on facebook https://plus.google.com/103440382717658277879 - our group in Google+ The data inside the database is held by the tables. The data can be inserted in these tables either by the queries or even with a straightaway Graphical method. In this tutorial we will see both the methods. Step 1 -- Locating the Appropriate Database First of all, we need to locate and expand the database where that particular table is present. After that, expand the table's directory. Then we will insert the data in the Inventory table. If we move into the column section, it can be seen that there are four fields which have to be added, namely the ID, the Product Name, the Quantity and the Price. Step 2 -- Writing query for inserting record Now to insert in table, SQL query would be: Insert into Inventory (id,Product,quantity,price) values (1,'abc',12,255.32); Make sure that each value is separated by a comma. Once done, simply press F5 to execute the query. At the bottom, in the messages section, a message will appear about table rows that have been affected. Step 3 -- Another Method of Insertion We can also insert data in a table by simply giving the values straight away. For that just write the following query: Insert into Inventory values (1,'ab2',30,300.36); Make sure that the values in query in SQL inserted into table are in the same order as the order of columns in the table. Now let's execute this query and in the messages section, you can see the rows that have been affected. To insert in table, SQL queries are required to be written with much care as error can arise if we just miss to insert ellipsis even. Step 4 -- Viewing Table Data Now let's check the table to see if the data has been inserted correctly. For that let us fetch all records from the inventory table and for that, write: Select * from inventory When we execute the query, you can see all the records in the results section below, and they are exactly the same as we mentioned in the query in earlier steps. Step 5 --Alternate Method of inserting data To insert in table, SQL provides another way through which we don't have to write SQL insert into table queries. For that, just right click on the inventory table and choose the 'Edit top 200 rows' option. Step 6 -- Inserting data in Fields Over here, we can start inserting the data in the table straight away, without using the queries. All we have to do is type the records in the fields and press enter to save the changes made in each field. And that is how data is inserted in tables in SQL using insert keyword.
Html code for embedding videos on your blog
Text Comments (17)
Beso moon (10 days ago)
How to Insert Into Table from table another without duplication in sql
TilFerLix (1 month ago)
Hello! what if i want to put an null data? what do i have to put? thx
RMIB (8 months ago)
Great video. If any of you need to create/improve any sql queries or you just have any questions, you can find me on fiverr! https://www.fiverr.com/ric_dev/create-fix-and-optimize-your-sql-queries
Afalaa (8 months ago)
Excellent explanation. In 2:45 wow 👍👍👍👍👍👍👍👍
Izuall90 (1 year ago)
please help me someone. how can i multiply product and quantity to insert price column. Insert into inventory(id, unit_price, quantity,price) values (2, 100,5, (unit_price *price)); but this wont work
Ken McColloch (1 year ago)
................. what?
tom hood (2 years ago)
I'm struggling with this
nikhil agrawal (2 years ago)
Error starting at line : 1 in command - INSERT INTO dryfruit_and_spices VALUES(DS1001,'NUTRAJ',1400,100,'500G','DRY FRUITS','ALMONDS','VEGETARIAN') Error at Command Line : 1 Column : 40 Error report - SQL Error: ORA-00984: column not allowed here 00984. 00000 - "column not allowed here" *Cause: *Action:
Abc Abc (2 years ago)
thank u sir u were very helpful
Happen2Bme (3 years ago)
Thank you so very much.  Clear explanation and easy to follow and thanks for the trick.
Victor Zamanian (3 years ago)
The product name wasn't typed within ellipses, was it? Looks like it was typed within single quotation marks... An ellipsis is three consecutive dots... Like I'm doing here...
Daniel Magdziarz (3 years ago)
But what if you just want to change data in only one field's multiple rows? Whenever I try to add data to only one field all the other rows in all of the fields are getting erased.
Barry Facer (3 years ago)
+Daniel Magdziarz Look at the update command. for example if you wanted to change name from abc to xxx in a customer table  update customer set name = 'xxx' where name = 'abc' this would change all instances of name abc to xxx . if there were other customers with name abc you would need to add more criteria to the where statement
Nemanja Jovic (3 years ago)
Very usefull tutorial, greetings from Serbia !
Portentous Lad (4 years ago)
that was quick.
Klent Gary Malig-on (4 years ago)
LoL you are in a Hurry? why so fast in speaking and explaining.
Amhadouch Mohammed (4 years ago)
thanks for the video bro 

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.