sp_helprotect

Does anyone know how can i use sp_helprotect just on the user tables and stored procedures..

thanks



Answer this question

sp_helprotect

  • JungleFreak

    Something like this will do it.

    declare @sSql varchar(300)

    DECLARE my_cursor cursor FOR
    SELECT sqlstm FROM #sql


    OPEN my_cursor


    FETCH NEXT FROM my_cursor INTO @sSql

    WHILE @@FETCH_STATUS = 0
    BEGIN

    insert into #result

    sp_execute(@sSql)

    FETCH NEXT FROM my_cursor INTO @sSql
    END

    CLOSE my_cursor

    DEALLOCATE my_cursor



  • itsnatraj

    Hi,

    You'll have to loop the objects you want to use.

    Try this:

    select 'exec ' & name as sqlstm into #sql from sysobjects where type in ('U', 'p')

    create table #result

    (

    owner varchar(100),

    object varchar(100),

    grantee varchar(100),

    grantor varchar(100),

    protecttype varchar(100),

    action varchar(100),

    column varchar(100)

    )

    loop #sql with a cursor --pseudo code

    insert into #result

    sp_execute(sqlstm)

    end loop --pseudo code

    Regards



  • Dexter L

    thanks for the reply, but i am really a beginner for the pseudo code....
  • sp_helprotect