Utility To Troubleshoot SQL INSERT Statements

Today I wrote a Windows application in C# to help me troubleshoot SQL INSERT statements which do not have an equal number of columns and values. Unfortunately, SQL Server does not provide very informative error messages. It can be difficult to figure out why an INSERT statement is invalid when you have a large number of table columns and a long string of values. My Windows application allows you to paste the SQL statement into a rich text box. When you click the Parse button it will display the number of column names and the number of column values so you can easily see if the counts do not match. It also displays the column names and values in a data grid view so you can more easily spot the value that does not match up.

Troubleshoot INSERT statement

I learned how to use regular expression match collections in writing this program. I also worked out how to create a dataset programmatically, define its columns, and add rows of data.

This entry was posted in Databases. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *