Generate SQL Update Statement And Stored Procedure From Table Name

Today I had to write a few simple update stored procedures and a couple of update statements. This got me thinking, seeing that I’m a SQL / .Net developer, I create loads of these every month.

I don’t like doing repetitive tasks so why not spend a  little time and write a script that generate these for me? So here it goes, here are two scripts and they are available as is. I know there are some data types that might not work or get excluded or throw exception etc etc etc…for the bulk of my work this will work a charm and in any case I need to check before I compile them.

Note: Your database context needs to be the same for the stored procedure/update statement as well as the table in question.

Execution for Update Statement

EXEC [GenerateUpdateStatementForTable] @TableName = 'Offices'

Read More »