Protecting a Query from Users

  • I create SQL queries that a number of people use, and sure enough it seems that every so often a comma gets added, or code goes missing. Is there a way to 'lock' a query from this sort of manipulation? Unfortunately some of the queries require the user to input information - so I am not sure this is possible.

    As an alternative, I may just create password protected word documents of the queries as back up.

  • Why don't you build a stored procedure that only allows inputs of things you want changed and can check for extraneous characters in the inputs. The you just publish

    EXE dbo.Sprocname

    @SomeParam1 = 'Jones Engineering Corp.',

    @SomeParam2 = 'xyz',

    @SomeParam3 = 'Some text',

    @SomeParam1 = 1234

    And it returns your results..

    CEWII

  • why dont you put your SQL code into a view, and let your users use that

  • msc (7/30/2009)


    why dont you put your SQL code into a view, and let your users use that

    Also a good answer..

    CEWII

  • Yes, and then revoke access for all the users on all objects except the procs and views, so that the users don't continue to run the old queries.

    John

  • John Mitchell (8/26/2009)


    Yes, and then revoke access for all the users on all objects except the procs and views, so that the users don't continue to run the old queries.

    John

    Definitely..

    CEWII

  • If you prefer to keep ad hoc querying available, you could use some form of source control for the queries.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply