Database Reference
In-Depth Information
Note GetDate() is SQL Server's built-in datetime function that returns the current date and time, so if you use
this function, it enters the current date and time into the column.
Figure 4-1. Inserting a new row into the MySqlTable table[[kim
How It Works
The first column, ID, is an identity column, and you can't insert values into it explicitly—the SQL Server
database engine will make sure that a unique and SQL Server-generated value is inserted for the ID field.
So, the INSERT statement needs to be written in such a way that you specify the column list you want to
insert values for explicitly; though the MySqlTable contains six fields, ID is an identity column, and it
does not expect any value to be inserted from the user. SQL Server can detect an identity column when
executing the INSERT statement. However, it is best practice to specify the column list and then pass the
respective values to these fields, as shown in the following query:
Insert into MySqlTable (Name,Age,SSN,Date,Gender)
Values('Rupali',31,'222-10-6789',GetDate(),'Female')
 
Search WWH ::




Custom Search