Solved

Trigger T-SQL

Posted on 2000-03-30
5
309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

630 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