Solved

Trigger T-SQL

Posted on 2000-03-30
5
299 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 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Select JOIN table 2 23
SQL Select Statement 2 22
SQL Server - Slabs 9 40
Early & clean exit from a maintenance plan (T-SQL Execution task) 5 21
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now