Unfortunately, things are not that easy for us mere mortals.  However, we can make many repeatable tasks much easier by automating them or supplying tools to simplify them.

I was having a conversation with someone the other day who saw the CRUD_Creator in our template and I realized I should probably post on it. To me writing simple CRUD (Create, Update, and Delete) statements for new tables can be boring so I updated one I made previously to fit our standards and patterns.

I typically use it as a quick starting point even if I need to modify it slightly based on requirements that way I can spend time on slightly more interesting things.

It is pretty simple. Just enter a few pieces of information into the script, such as the table schema and name you want the procedures created for, your name and the task number, and whether you want to just print out the procedures to add or if you want to execute / create them directly on the database. I recommend printing them and then copying the ones you need into the database project after reviewing, and /or tweaking it.

crud_var

Here is a summary of what you get for output. See the attached SAMPLE_CRUD_Output.txt file below for the actual output.

  1. A basic Insert procedure that returns the identity value for the record
  2. A basic update procedure for a specific record
  3. A basic delete procedure for a specific record
  4. A basic select procedure listing the table results
  5. A basic select procedure returning the table results for a specific record

I have attached the code to this in case you want to check it out without pulling it down from subversion.

Feel free to use and improve them at your pleasure.

Do you have any tools you use regularly? What are they?

Let us know in the comments below.