Home All Groups Group Topic Archive Search About

trigger on system table

Author
11 Nov 2005 5:44 AM
chaujohnthan
i can add trigger to system table by
changing sysobject records.
but it doesn't fire.

this is really needed, why not?

Author
11 Nov 2005 6:32 AM
David Portas
"chaujohnthan" <chaujohnthan at hotmail.com> wrote in message
news:OyabwNo5FHA.2560@TK2MSFTNGP12.phx.gbl...
>i can add trigger to system table by
> changing sysobject records.
> but it doesn't fire.
>
> this is really needed, why not?
>

Never modify system tables. Doing so could corrupt your database and render
it unusable. Triggers aren't supported on system tables because they aren't
all "real" tables - many are just virtual structures for exposing system
data.

To track schema changes in SQL Server 2000 use a source control system or
some third-party utility like RedGate SQL Compare or DBGhost. In SQL Server
2005 you can use a DDL trigger.

--
David Portas
SQL Server MVP
--
Author
11 Nov 2005 10:55 AM
ML
Please elaborate on "really needed", and we can help you find a solution.


ML
Author
11 Nov 2005 4:07 PM
chaujohnthan
i am designing security  for an web OA project.

so i am using sql server user as employee.
when managing employee, i need to trigger sth,
just like hr dept does. this means i need to
cooperate with sysxlogin or sysusers by way of
foreign key constraint or trigger. but the
sql2000 designer disallow this.

so i had to upgrade to .net? or stuck here
crying?


Show quote
"ML" <M*@discussions.microsoft.com> дÈëÏûÏ¢ÐÂÎÅ:78C3C80A-7491-45AC-8E56-BC6B5373C***@microsoft.com...
> Please elaborate on "really needed", and we can help you find a solution.
>
>
> ML
Author
11 Nov 2005 4:26 PM
David Portas
Why not populate your own user table as part of the process that
creates the login?

In any case, in a web app, why do you need to create a SQL login for
each user? More conventionally in an N-tier application you need only
have a single SQL login for the app or maybe a single login for each
user security profile. Alternatively, use integrated security
throughout. Grant only you EXECUTE permissions to the user and enforce
any row-level security in your procs.

--
David Portas
SQL Server MVP
--
Author
11 Nov 2005 4:33 PM
ML
Are you trying to say that you need a way to make sure the user name being
inserted into your table belongs to a valid SQL user?

if (not exists (
    select *
              from syslogins
              where ([name] = @<username>)
    ))
    begin
        raiserror ('Unknown user %s.', 16, 1, @<username>)
        return -1
    end

Something like that?


ML

AddThis Social Bookmark Button