Learn more about SQL Server tools

mssqltips logo

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

SQL Server Transparent Data Encryption Alternative - Free Webinar

Verify INSERT logic with SQL Server SELECT command



Once you have executed the three commands it is time to verify the results.  How can we accomplish this?  We have to issue SELECT statements to review the data.  You did not think you were going to get exposed to another command, did you?


In the code below, we are retrieving all of the columns and all of the rows from the dbo.Customers table.

SELECT CustomerID,
FROM dbo.Customer;

Here are the results:

SQL Server SELECT statement to verify the INSERT statement

As you can see in the first example above, the first row has the following:

  • All of the columns have the values from the INSERT command above.

In the second example above, the second row has the following:

  • All of the columns have the values from the INSERT command above with the exception of the CreateDate column which was recorded when the record was inserted.

In the third example above, the third row has the following:

  • All of the columns have the values from the INSERT command above including NULL for the EmailAddress column.

As you can see from the code and data above, all three rows were properly inserted into the dbo.Customer table.  Although they are all correct, I would generally recommend using the syntax from the first example because it is the most complete and there is little guesswork as to the final values.

For more information about the SELECT command, check out the SQL Server SELECT tutorial.

Now that we have covered three basic examples, let's see how else we can use the INSERT command.

Last Update: 9/16/2011

More SQL Server Solutions

Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 

Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.


Learn more about SQL Server tools