Solved

Trigger T-SQL

Posted on 2000-03-30
5
304 Views
Last Modified: 2012-06-22
I'd like the t-sql that would make a trigger which would,whenever a change in permissions or indexes was made to a table or view, it would populate a table(logtable) with getdate(), the id making the change , generate sql script of the original and the new in directory called original and new.
If the points seem stingy, that can be negotiated.
0
Comment
Question by:xoxomos
  • 3
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2672110
If you find something like that, let me know!!!
What i use to version scripts, is that I generate scripts manually (using the Scripting Wizard), even if I could use SQL-DMO...

Thinking about this, you could add a trigger to master database tables: syscolumns, sysobjects, sysindexes ...
Sounds like a challenge ...

0
 
LVL 4

Accepted Solution

by:
kpkp earned 50 total points
ID: 2672686
In SQL7 you could try adding a trigger to the SysPermissions table.  Something like this would work for an insert trigger and record all new permissions granted...


INSERT INTO LogTable
      SELECT SysObjects.Name AS Object,
      SysUsersGe.Name AS Grantee,
      SysUsersGo.Name AS Grantor,
      SysPermissions.ActAdd AS GrantedAllCol,
      SysPermissions.ActMod AS DeniedAllCol,
      SysPermissions.SelAdd AS GrantedSelect,
      SysPermissions.SelMod AS DeniedSelect,
      SysPermissions.UpdAdd AS GrantedUpdate,
      SysPermissions.UpdMod AS DeniedUpdate,
      SysPermissions.UpdAdd AS GrantedUpdate,
      SysPermissions.UpdMod AS DeniedUpdate,
      SysPermissions.UpdAdd AS GrantedReferences,
      SysPermissions.UpdMod AS DeniedReferences
      FROM Inserted SysPermissions
      JOIN SysObjects ON SysObjects.ID = SysPermissions.ID
      JOIN SysUsers SysUsersGe ON SysUsersGe.UID = SysPermissions.grantee
      JOIN SysUsers SysUsersGo ON SysUsersGo.UID = SysPermissions.grantor


For more detailed info on the columns in SysPermissions take a look at http://msdn.microsoft.com/library/techart/sql7security.htm
0
 

Author Comment

by:xoxomos
ID: 2673865
Forgot to mention, i'm on 6.5
0
 

Author Comment

by:xoxomos
ID: 2674053
Forgot to mention, i'm on 6.5
0
 

Author Comment

by:xoxomos
ID: 2674083
Installed a trial version of 7.0 .  Don't understand quite i'm seeing just yet, but that looks what i could use IF i had 7.0.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question