SQL Server Performance

Easy-to-Use generic SQL procedure

Discussion in 'Contribute Your SQL Server Scripts' started by wabbash, Mar 18, 2004.

  1. wabbash New Member

    I have found this procedure pretty useful for Developers ...

    It works both with 6.5 and 2000
    It is intended for "ONE SELECT statement"-> ONE single result (integer this time)

    CREATE PROCEDURE sp_xExecGenericSQL

    @strSQL varchar(255),
    @intParOut int output

    AS
    DECLARE @cmd varchar(255)
    DECLARE @result smallint

    SET NOCOUNT ON

    select @cmd='DECLARE myCursor CURSOR FOR '
    select @cmd= @cmd + @strSQL
    exec (@cmd)
    open myCursor

    fetch myCursor into @intParOut

    close myCursor
    deallocate myCursor

    return(@intParOut)
    GO


    ------------------------ No one travels so high as he who knows not where he is going... {{Oliver Cromwell}}
  2. Chappy New Member

    Could be useful, but be careful this isnt abused by lazy developers <img src='/community/emoticons/emotion-1.gif' alt=':)' /><br />ie.. making several calls to this procedure to get a few values (because its there and ready) rather than writing a better performing sp to do it
  3. wabbash New Member

    developers in my department are even more lazy than that an prefer to develop their own "known" stuff than learn a new procedure which could help a lot ...

    developers developers!!!

Share This Page