![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, I have an existing table(Several actually) that I want to add a column or two or three. I need to have, I think, at least two columns. One for Created date and believe this is a no brainer in that I just add the column and set the default to getdate(). Two, for tracking a modified date of the row of data. I want to keep it simple. What do I do to track the modify date of a row in SQL Server 2005? Anytime any data changes on a row update the update column? Is a trigger the only way to accomplish this task? |
|
Another column could be used to track who changed it. Is there a neat way to determine username, machine name, MAC address or any other method? I pretty wide open on this one as I am not sure what I want to use here. |
#3
| |||
| |||
|
|
Another column could be used to track who changed it. Is there a neat way to determine username, machine name, MAC address or any other method? I pretty wide open on this one as I am not sure what I want to use here. Check out SUSER_SNAME() and HOST_NAME() in Books Online. |
#4
| |||
| |||
|
|
Hugo Kornelis (h... (AT) perFact (DOT) REMOVETHIS.info.INVALID) writes: Another column could be used to track who changed it. Is there a neat way to determine username, machine name, MAC address or any other method? I pretty wide open on this one as I am not sure what I want to use here. Check out SUSER_SNAME() and HOST_NAME() in Books Online. There's far too many functions for the current user for it to be healthy. The best to use, though, is probably original_login(), because the others (SESSION_USER, SYSTEM_USER, suser_sname() etc) gives incorrect information if there is an EXECUTE AS clause somewhere along the line. -- Erland Sommarskog, SQL Server MVP, esq... (AT) sommarskog (DOT) se Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books... Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
#5
| |||
| |||
|
|
Are there examples of creating a trigger for tracking table data changes? Since I never created one before. |
#6
| |||
| |||
|
|
On Dec 4, 4:33 pm, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote: Hugo Kornelis (h... (AT) perFact (DOT) REMOVETHIS.info.INVALID) writes: Another column could be used to track who changed it. Is there a neat way to determine username, machine name, MAC address or any other method? I pretty wide open on this one as I am not sure what I want to use here. Check out SUSER_SNAME() and HOST_NAME() in Books Online. There's far too many functions for the current user for it to be healthy. The best to use, though, is probably original_login(), because the others (SESSION_USER, SYSTEM_USER, suser_sname() etc) gives incorrect information if there is an EXECUTE AS clause somewhere along the line. -- Erland Sommarskog, SQL Server MVP, esq... (AT) sommarskog (DOT) se Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books... Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx Thanks for the replies. Are there examples of creating a trigger for tracking table data changes? Since I never created one before. Thanks again... |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
You need to look a third party audit tool that will meet the legal requirements. Think about what happens when you do a delete or the DB crashes. What are you going to tell the court? |
#9
| |||
| |||
|
|
You need to look a third party audit tool that will meet the legal requirements. Think about what happens when you do a delete or the DB crashes. What are you going to tell the court? |
#10
| |||
| |||
|
|
you are jumping to conclusions without knowing anything about the problem. What if there are no legal issues at all? |
And if there isn't one![]() |
| Thread Tools | |
| Display Modes | |
| |