Welcome to Pegasus Mail & Mercury Sign in | Join | Help

Peter Strömblad

Peter lives in Sweden and is an independent contractor with hosting services.
Repetitive work in SQL

Just wanted to share the two SQL scripts I produced last week. They are stored procedures that create standard looking CreateUpdate and Get procedures for any given table in SQL-Server. I've published the scripts at sqlservercentral.com and they are free to use and tweak.

Stored procedure mkProc_CreateUpdate

Stored procedure mkProc_Get

Here is a brief description for both of the procedures

mkProc_CreateUpdate v1.0 (c) Petena AB 1993-2008, http://www.petena.se/, http://www.praktit.se/

 Creates stored procedure of given table name for the purpose of adding or updating a record
    Primary keys are to be set to null to trigger the insert, and the key is returned.
    Signals null/not null and default values.

    Input Params:
        @_tableName - the table you want to script
        @prefix - add string here if you want your stored procedure name prefixed, like 'sp_'
        @AddParams - add additional parameters to the stored procedure call
        @DoCreate - true/false : when true the stored procedure is created
        @Debug - true/false : true only works when @DoCreate is false, presents all internal tables
    
    Example: Exec mkProc_CreateUpdate 'Orders', 'crm_', '@userID int,' false, true

Posted: Thursday, September 04, 2008 8:14 PM by Peter Strömblad

Comments

No Comments

Anonymous comments are disabled