Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Trigger T-SQL

Posted on 2000-03-30
5
Medium Priority
?
310 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 150 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
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
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

670 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