How to Insert Date in SQL?

by Dinesh 2012-09-17 10:24:55

<h3>How to Insert Date in SQL?</h3>There are basically two ways to INSERT data into a table: One is to insert it one row at a time, the other is to insert multiple rows at a time. In this section, we'll take a look at the first case:

The syntax for inserting data into a table one row at a time is as follows:

INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...)

Assuming that we have a table that has the following structure,

Table Store_Information
----------------------------------
Column Name | Data Type |
----------------------------------
store_name | char(50) |
----------------------------------
Sales | float |
----------------------------------
Date | datetime |
----------------------------------

and now we wish to insert one additional row into the table representing the sales data for Los Angeles on January 10, 1999. On that day, this store had $900 in sales. We will hence use the following SQL script:

INSERT INTO Store_Information (store_name, Sales, Date)
VALUES ('Los Angeles', 900, 'Jan-10-1999')

Tagged in:

522
like
0
dislike
0
mail
flag

You must LOGIN to add comments