Tuesday, March 27, 2012
Auto Create Statistics
one of our production databases. When we told the group responsible for the
application for this database, they said they have been having performance
issues and are enquiring if having this setting turned on could be the cause
of that.
From BOL, with automatic statistics, the statistics are updated periodically
as the data in the table changes. A statistics update occurs whenever the
statistics in a query execution fail a test for the current statistics.
Statistical information is updated whenever approximately 20 percent of the
data rows have been changed.
Is it possible that this overhead could have an affect on database
performance?
Also, they asked if we could give then a report for displaying all the
statistics. I know the "DBBC SHOW_STATISTICS" command will display the
statistics if you supply the table and index parameters. The database is
quite large with many tables and indexes. I could probably write a script
using cursors but I am wondering if there is any other way for generating a
report for all of the statistics for the database.Hi Loren
This setting is ON by default on all databases, and it is usually a good
idea to leave it on. In addition, this setting is not the same as AUTO
UPDATE STATISTICS. Since this was most likely on since the time the db was
created, it's unlikely that it is the cause for any recent performance
problems.
AUTO CREATE STATISTICS tells SQL Server to create stats on unindexed
columns. AUTO UPDATE STATISTICS tells SQL Server to update index statistics
when they get stale.
Actually looking at statistics is rarely needed, and most people do it only
when troubleshooting one particular query that is misbehaving. Why do they
want a report for ALL the statistics when they are subject to frequent
change? By the time they got through looking at the whole report, the values
would probably have changed.
I would think the DBCC SHOW_STATISTICS would be good enough, when they need
to look at particular statistics for a particular table or index.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://sqlblog.com
"Loren Z" <anonymous@.discussions.microsoft.com> wrote in message
news:e4gI9NSBIHA.1168@.TK2MSFTNGP02.phx.gbl...
> We have accidentally had the "Auto Create Statistics" turned set to true
> on one of our production databases. When we told the group responsible for
> the application for this database, they said they have been having
> performance issues and are enquiring if having this setting turned on
> could be the cause of that.
> From BOL, with automatic statistics, the statistics are updated
> periodically as the data in the table changes. A statistics update occurs
> whenever the statistics in a query execution fail a test for the current
> statistics. Statistical information is updated whenever approximately 20
> percent of the data rows have been changed.
> Is it possible that this overhead could have an affect on database
> performance?
> Also, they asked if we could give then a report for displaying all the
> statistics. I know the "DBBC SHOW_STATISTICS" command will display the
> statistics if you supply the table and index parameters. The database is
> quite large with many tables and indexes. I could probably write a script
> using cursors but I am wondering if there is any other way for generating
> a report for all of the statistics for the database.
>|||As far as I know, this post was asking about Auto CREATE Statistics, not
AUTO UPDATE.
Yes, AUTO UPDATE does have a cost, but in most cases, updating stats and
recompiling has far less of a cost than the costs of using a bad plan
because your statistics are out of date. SQL 2005 also introduced AUTO
UPDATE STATISTICS ASYNC, so that the stats will be automatically updated,
but it will not impact the query that triggered the update, i.e. that query
will not have to wait for the update and the subsequent recompile.
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://sqlblog.com
"Ekrem Önsoy" <ekrem@.btegitim.com> wrote in message
news:4AF1D2DE-60B6-4C24-9F60-3BA208A222F1@.microsoft.com...
> Hello Kalen!
>
> As far as I know Auto Update Statistics cause changing Query Plans and
> causes SPs to be recompiled so this makes a performance problem. I know
> that if statistics would be ouf of date, then it's another problem. This
> seems kind of dilemma.
> I would be happy to hear your comments about this.
>
> --
> Ekrem Önsoy
>
> "Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
> news:ekdDiSSBIHA.536@.TK2MSFTNGP06.phx.gbl...
>> Hi Loren
>> This setting is ON by default on all databases, and it is usually a good
>> idea to leave it on. In addition, this setting is not the same as AUTO
>> UPDATE STATISTICS. Since this was most likely on since the time the db
>> was created, it's unlikely that it is the cause for any recent
>> performance problems.
>> AUTO CREATE STATISTICS tells SQL Server to create stats on unindexed
>> columns. AUTO UPDATE STATISTICS tells SQL Server to update index
>> statistics when they get stale.
>> Actually looking at statistics is rarely needed, and most people do it
>> only when troubleshooting one particular query that is misbehaving. Why
>> do they want a report for ALL the statistics when they are subject to
>> frequent change? By the time they got through looking at the whole
>> report, the values would probably have changed.
>> I would think the DBCC SHOW_STATISTICS would be good enough, when they
>> need to look at particular statistics for a particular table or index.
>> --
>> HTH
>> Kalen Delaney, SQL Server MVP
>> www.InsideSQLServer.com
>> http://sqlblog.com
>>
>> "Loren Z" <anonymous@.discussions.microsoft.com> wrote in message
>> news:e4gI9NSBIHA.1168@.TK2MSFTNGP02.phx.gbl...
>> We have accidentally had the "Auto Create Statistics" turned set to true
>> on one of our production databases. When we told the group responsible
>> for the application for this database, they said they have been having
>> performance issues and are enquiring if having this setting turned on
>> could be the cause of that.
>> From BOL, with automatic statistics, the statistics are updated
>> periodically as the data in the table changes. A statistics update
>> occurs whenever the statistics in a query execution fail a test for the
>> current statistics. Statistical information is updated whenever
>> approximately 20 percent of the data rows have been changed.
>> Is it possible that this overhead could have an affect on database
>> performance?
>> Also, they asked if we could give then a report for displaying all the
>> statistics. I know the "DBBC SHOW_STATISTICS" command will display the
>> statistics if you supply the table and index parameters. The database is
>> quite large with many tables and indexes. I could probably write a
>> script using cursors but I am wondering if there is any other way for
>> generating a report for all of the statistics for the database.
>>
>|||Hello Kalen!
As far as I know Auto Update Statistics cause changing Query Plans and
causes SPs to be recompiled so this makes a performance problem. I know that
if statistics would be ouf of date, then it's another problem. This seems
kind of dilemma.
I would be happy to hear your comments about this.
Ekrem Önsoy
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:ekdDiSSBIHA.536@.TK2MSFTNGP06.phx.gbl...
> Hi Loren
> This setting is ON by default on all databases, and it is usually a good
> idea to leave it on. In addition, this setting is not the same as AUTO
> UPDATE STATISTICS. Since this was most likely on since the time the db was
> created, it's unlikely that it is the cause for any recent performance
> problems.
> AUTO CREATE STATISTICS tells SQL Server to create stats on unindexed
> columns. AUTO UPDATE STATISTICS tells SQL Server to update index
> statistics when they get stale.
> Actually looking at statistics is rarely needed, and most people do it
> only when troubleshooting one particular query that is misbehaving. Why do
> they want a report for ALL the statistics when they are subject to
> frequent change? By the time they got through looking at the whole report,
> the values would probably have changed.
> I would think the DBCC SHOW_STATISTICS would be good enough, when they
> need to look at particular statistics for a particular table or index.
> --
> HTH
> Kalen Delaney, SQL Server MVP
> www.InsideSQLServer.com
> http://sqlblog.com
>
> "Loren Z" <anonymous@.discussions.microsoft.com> wrote in message
> news:e4gI9NSBIHA.1168@.TK2MSFTNGP02.phx.gbl...
>> We have accidentally had the "Auto Create Statistics" turned set to true
>> on one of our production databases. When we told the group responsible
>> for the application for this database, they said they have been having
>> performance issues and are enquiring if having this setting turned on
>> could be the cause of that.
>> From BOL, with automatic statistics, the statistics are updated
>> periodically as the data in the table changes. A statistics update occurs
>> whenever the statistics in a query execution fail a test for the current
>> statistics. Statistical information is updated whenever approximately 20
>> percent of the data rows have been changed.
>> Is it possible that this overhead could have an affect on database
>> performance?
>> Also, they asked if we could give then a report for displaying all the
>> statistics. I know the "DBBC SHOW_STATISTICS" command will display the
>> statistics if you supply the table and index parameters. The database is
>> quite large with many tables and indexes. I could probably write a script
>> using cursors but I am wondering if there is any other way for generating
>> a report for all of the statistics for the database.
>|||Yes, I know that post was about CREATE STATISTICS. However, when you
mentioned Update Statistics, I wanted to have your comments about this.
Thanks for sharing your thoughts about this.
--
Ekrem Önsoy
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:O1gT8wSBIHA.4656@.TK2MSFTNGP04.phx.gbl...
> As far as I know, this post was asking about Auto CREATE Statistics, not
> AUTO UPDATE.
> Yes, AUTO UPDATE does have a cost, but in most cases, updating stats and
> recompiling has far less of a cost than the costs of using a bad plan
> because your statistics are out of date. SQL 2005 also introduced AUTO
> UPDATE STATISTICS ASYNC, so that the stats will be automatically updated,
> but it will not impact the query that triggered the update, i.e. that
> query will not have to wait for the update and the subsequent recompile.
> --
> HTH
> Kalen Delaney, SQL Server MVP
> www.InsideSQLServer.com
> http://sqlblog.com
>
> "Ekrem Önsoy" <ekrem@.btegitim.com> wrote in message
> news:4AF1D2DE-60B6-4C24-9F60-3BA208A222F1@.microsoft.com...
>> Hello Kalen!
>>
>> As far as I know Auto Update Statistics cause changing Query Plans and
>> causes SPs to be recompiled so this makes a performance problem. I know
>> that if statistics would be ouf of date, then it's another problem. This
>> seems kind of dilemma.
>> I would be happy to hear your comments about this.
>>
>> --
>> Ekrem Önsoy
>>
>> "Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
>> news:ekdDiSSBIHA.536@.TK2MSFTNGP06.phx.gbl...
>> Hi Loren
>> This setting is ON by default on all databases, and it is usually a good
>> idea to leave it on. In addition, this setting is not the same as AUTO
>> UPDATE STATISTICS. Since this was most likely on since the time the db
>> was created, it's unlikely that it is the cause for any recent
>> performance problems.
>> AUTO CREATE STATISTICS tells SQL Server to create stats on unindexed
>> columns. AUTO UPDATE STATISTICS tells SQL Server to update index
>> statistics when they get stale.
>> Actually looking at statistics is rarely needed, and most people do it
>> only when troubleshooting one particular query that is misbehaving. Why
>> do they want a report for ALL the statistics when they are subject to
>> frequent change? By the time they got through looking at the whole
>> report, the values would probably have changed.
>> I would think the DBCC SHOW_STATISTICS would be good enough, when they
>> need to look at particular statistics for a particular table or index.
>> --
>> HTH
>> Kalen Delaney, SQL Server MVP
>> www.InsideSQLServer.com
>> http://sqlblog.com
>>
>> "Loren Z" <anonymous@.discussions.microsoft.com> wrote in message
>> news:e4gI9NSBIHA.1168@.TK2MSFTNGP02.phx.gbl...
>> We have accidentally had the "Auto Create Statistics" turned set to
>> true on one of our production databases. When we told the group
>> responsible for the application for this database, they said they have
>> been having performance issues and are enquiring if having this setting
>> turned on could be the cause of that.
>> From BOL, with automatic statistics, the statistics are updated
>> periodically as the data in the table changes. A statistics update
>> occurs whenever the statistics in a query execution fail a test for the
>> current statistics. Statistical information is updated whenever
>> approximately 20 percent of the data rows have been changed.
>> Is it possible that this overhead could have an affect on database
>> performance?
>> Also, they asked if we could give then a report for displaying all the
>> statistics. I know the "DBBC SHOW_STATISTICS" command will display the
>> statistics if you supply the table and index parameters. The database
>> is quite large with many tables and indexes. I could probably write a
>> script using cursors but I am wondering if there is any other way for
>> generating a report for all of the statistics for the database.
>>
>>
>
Sunday, March 11, 2012
Auditing SQL Server 2005 through transaction log
Hello,
We are maintaining an internal ASP.NET v2.0 website which is quite big and already in production. The underlying SQL Server 2005 database contains 350+ tables.
Recently, we have been asked to implement a new feature which seems functionally quite simple. We have to track every single data modification, which includes insertions, deletions and modifications. This information should be presented to power users in the form of readable strings right in an admin section of our website.
Our team of architects is working on a way to make it possible without putting the SQL Server to a crawl. One thing is for sure, SQL Server 2005 already does the job through its transaction log. It should be a good idea to use it directly instead of managing our own log based on triggers. Why put more pressure on the server to write data that is already logged by the database engine? We have heard that Microsoft's SQL Server team do not support this concept and are wondering why...
It's quite easy to find queries on the web that output very useful information such as date of transactions and what they have done. Although, the data involved in those transactions seems to be stored in a binary field which can be retrived using this query: SELECT "log record" FROM ::fn_dblog(null,null)
3rd parties such as Apex SQL are already doing a great job at decrypting it for us. This is very useful but not efficient since those tools do a very generic job. We would like to optimize it for our needs. All we need to know is who made the modifications, when, in which tables and what are the new values.
We believe that we would have to decrypt the "log record" field from the ::fn_dblog(null, null) table. Is there any way to get basic documentation about how to do it?
Thanks!
Marc Lacoursiere
RooSoft Computing
The format of the transaction log is undocumented, as it will change from release to release.Thanks,|||
Hi,
I'm working with Marc on that point and I would like to know if there is or if Microsoft expect to expose an interface that can allow us to read the transaction log. What are the plans for futur releases.
Thanks
|||The transaction log contains physical information that are often just blocks of bytes which are meaningless in terms of the DDL or DML that instigated them. The log was never intended for audit purposes and really should not be used that way.|||Thanks for your Post Peter,
I understand that the transaction log purpose is for recovery only but you must admit that it could be a great way to audit changes without adding any overhead to the server.
What we would like to do is taking a transaction log backup on a regulary basis and read those files as they cumulated in the directory. This will allow us to log any DML changes into a Log table located on another server.
I also understand that the online transaction log format can change from one version to another but correct me if I'm wrong, the transaction log backup is compatible between SQL 2000 and SQL 2005 that means that the format of a .trn file should remain compatible as SQL Server evoluate.
thanks for your feedback|||Adding the information needed to use the log for auditing would add significant overhead which is one of the reasons it has not been done.
You might look at the Change Data Capture functionality in the upcoming SQL Server 2008 release. http://connect.microsoft.com/sqlserver/ has a CTP preview release available.
|||Our guess as of now is that some timely transaction log backup analysis on a remote machine could help keep our database server usage to an acceptable level as it already handles loads of data.
We doubt that using triggers on each table would be much more effective. This would certainly slow down every transaction. As our database grows, we must optimize DML operations to keep the website running fast.
|||>> SELECT "log record" FROM ::fn_dblog(null,null)
>> All we need to know is who made the modifications, when, in which tables and what are the new values.
"Who" is not available on a log record by log record basis. It is not part of that binary data in most cases. There are some few records that contain a "who" such as BEGIN TRAN log records. This is included in other output columns of fn_dblog().
When is not available on a log record by log record basis. There are some few record types that contain a "when" such as BEGIN TRAN and END TRAN log records. These are included as other columns in fn_dblog().
Which table is not actually stored in the log record in SQL 2005 and later. This is due to partitioning. The partition has to be linked through the catalog metadata back to its base table and index. This is attempted by fn_dblog() itself and shows up as other columns in the output. DDL can make this lookup fail.
"New values" are often just a byte by byte binary diff of the old row from the new row, not the full values themselves. The log record code does not actually know how to crack the row binary data, it just passes it along to other components in the system. i.e., if you update a INT column from a value of 1 to a value of 257, we may only log a single byte 0x01 as the difference.
The SQL 2005 output for fn_dblog() has been supplemented to try to make some of this easier, but the reality is that some of what you want is just not in the log in many cases.
Thanks Peter for this interesting complement of information.
We actually take care of the "When" and the "Who" because each table of our database contain an updatedBy and updatedDt column. These columns are systematicly updated on each changes by the application layer. We only need to find the new values of the modification.
For the byte by byte binary diff, I guess that you are talking about the online transaction log because taking a closer look at the transaction log backup file (.trn) indicates that new values are stored in the file. I've opened it with an hex editor and I was able to see the new inserted values.
|||You could look at AuditDB of Lumigent, can be customized on details what you demand.
With best regards.
Jan H. Kanon
Auditing SQL Server 2005 through transaction log
Hello,
We are maintaining an internal ASP.NET v2.0 website which is quite big and already in production. The underlying SQL Server 2005 database contains 350+ tables.
Recently, we have been asked to implement a new feature which seems functionally quite simple. We have to track every single data modification, which includes insertions, deletions and modifications. This information should be presented to power users in the form of readable strings right in an admin section of our website.
Our team of architects is working on a way to make it possible without putting the SQL Server to a crawl. One thing is for sure, SQL Server 2005 already does the job through its transaction log. It should be a good idea to use it directly instead of managing our own log based on triggers. Why put more pressure on the server to write data that is already logged by the database engine? We have heard that Microsoft's SQL Server team do not support this concept and are wondering why...
It's quite easy to find queries on the web that output very useful information such as date of transactions and what they have done. Although, the data involved in those transactions seems to be stored in a binary field which can be retrived using this query: SELECT "log record" FROM ::fn_dblog(null,null)
3rd parties such as Apex SQL are already doing a great job at decrypting it for us. This is very useful but not efficient since those tools do a very generic job. We would like to optimize it for our needs. All we need to know is who made the modifications, when, in which tables and what are the new values.
We believe that we would have to decrypt the "log record" field from the ::fn_dblog(null, null) table. Is there any way to get basic documentation about how to do it?
Thanks!
Marc Lacoursiere
RooSoft Computing
The format of the transaction log is undocumented, as it will change from release to release.Thanks,|||
Hi,
I'm working with Marc on that point and I would like to know if there is or if Microsoft expect to expose an interface that can allow us to read the transaction log. What are the plans for futur releases.
Thanks
|||The transaction log contains physical information that are often just blocks of bytes which are meaningless in terms of the DDL or DML that instigated them. The log was never intended for audit purposes and really should not be used that way.|||Thanks for your Post Peter,
I understand that the transaction log purpose is for recovery only but you must admit that it could be a great way to audit changes without adding any overhead to the server.
What we would like to do is taking a transaction log backup on a regulary basis and read those files as they cumulated in the directory. This will allow us to log any DML changes into a Log table located on another server.
I also understand that the online transaction log format can change from one version to another but correct me if I'm wrong, the transaction log backup is compatible between SQL 2000 and SQL 2005 that means that the format of a .trn file should remain compatible as SQL Server evoluate.
thanks for your feedback|||Adding the information needed to use the log for auditing would add significant overhead which is one of the reasons it has not been done.
You might look at the Change Data Capture functionality in the upcoming SQL Server 2008 release. http://connect.microsoft.com/sqlserver/ has a CTP preview release available.
|||Our guess as of now is that some timely transaction log backup analysis on a remote machine could help keep our database server usage to an acceptable level as it already handles loads of data.
We doubt that using triggers on each table would be much more effective. This would certainly slow down every transaction. As our database grows, we must optimize DML operations to keep the website running fast.
|||>> SELECT "log record" FROM ::fn_dblog(null,null)
>> All we need to know is who made the modifications, when, in which tables and what are the new values.
"Who" is not available on a log record by log record basis. It is not part of that binary data in most cases. There are some few records that contain a "who" such as BEGIN TRAN log records. This is included in other output columns of fn_dblog().
When is not available on a log record by log record basis. There are some few record types that contain a "when" such as BEGIN TRAN and END TRAN log records. These are included as other columns in fn_dblog().
Which table is not actually stored in the log record in SQL 2005 and later. This is due to partitioning. The partition has to be linked through the catalog metadata back to its base table and index. This is attempted by fn_dblog() itself and shows up as other columns in the output. DDL can make this lookup fail.
"New values" are often just a byte by byte binary diff of the old row from the new row, not the full values themselves. The log record code does not actually know how to crack the row binary data, it just passes it along to other components in the system. i.e., if you update a INT column from a value of 1 to a value of 257, we may only log a single byte 0x01 as the difference.
The SQL 2005 output for fn_dblog() has been supplemented to try to make some of this easier, but the reality is that some of what you want is just not in the log in many cases.
Thanks Peter for this interesting complement of information.
We actually take care of the "When" and the "Who" because each table of our database contain an updatedBy and updatedDt column. These columns are systematicly updated on each changes by the application layer. We only need to find the new values of the modification.
For the byte by byte binary diff, I guess that you are talking about the online transaction log because taking a closer look at the transaction log backup file (.trn) indicates that new values are stored in the file. I've opened it with an hex editor and I was able to see the new inserted values.
|||You could look at AuditDB of Lumigent, can be customized on details what you demand.
With best regards.
Jan H. Kanon
Auditing SQL Server 2005 through transaction log
Hello,
We are maintaining an internal ASP.NET v2.0 website which is quite big and already in production. The underlying SQL Server 2005 database contains 350+ tables.
Recently, we have been asked to implement a new feature which seems functionally quite simple. We have to track every single data modification, which includes insertions, deletions and modifications. This information should be presented to power users in the form of readable strings right in an admin section of our website.
Our team of architects is working on a way to make it possible without putting the SQL Server to a crawl. One thing is for sure, SQL Server 2005 already does the job through its transaction log. It should be a good idea to use it directly instead of managing our own log based on triggers. Why put more pressure on the server to write data that is already logged by the database engine? We have heard that Microsoft's SQL Server team do not support this concept and are wondering why...
It's quite easy to find queries on the web that output very useful information such as date of transactions and what they have done. Although, the data involved in those transactions seems to be stored in a binary field which can be retrived using this query: SELECT "log record" FROM ::fn_dblog(null,null)
3rd parties such as Apex SQL are already doing a great job at decrypting it for us. This is very useful but not efficient since those tools do a very generic job. We would like to optimize it for our needs. All we need to know is who made the modifications, when, in which tables and what are the new values.
We believe that we would have to decrypt the "log record" field from the ::fn_dblog(null, null) table. Is there any way to get basic documentation about how to do it?
Thanks!
Marc Lacoursiere
RooSoft Computing
The format of the transaction log is undocumented, as it will change from release to release.Thanks,|||
Hi,
I'm working with Marc on that point and I would like to know if there is or if Microsoft expect to expose an interface that can allow us to read the transaction log. What are the plans for futur releases.
Thanks
|||The transaction log contains physical information that are often just blocks of bytes which are meaningless in terms of the DDL or DML that instigated them. The log was never intended for audit purposes and really should not be used that way.|||Thanks for your Post Peter,
I understand that the transaction log purpose is for recovery only but you must admit that it could be a great way to audit changes without adding any overhead to the server.
What we would like to do is taking a transaction log backup on a regulary basis and read those files as they cumulated in the directory. This will allow us to log any DML changes into a Log table located on another server.
I also understand that the online transaction log format can change from one version to another but correct me if I'm wrong, the transaction log backup is compatible between SQL 2000 and SQL 2005 that means that the format of a .trn file should remain compatible as SQL Server evoluate.
thanks for your feedback|||Adding the information needed to use the log for auditing would add significant overhead which is one of the reasons it has not been done.
You might look at the Change Data Capture functionality in the upcoming SQL Server 2008 release. http://connect.microsoft.com/sqlserver/ has a CTP preview release available.
|||Our guess as of now is that some timely transaction log backup analysis on a remote machine could help keep our database server usage to an acceptable level as it already handles loads of data.
We doubt that using triggers on each table would be much more effective. This would certainly slow down every transaction. As our database grows, we must optimize DML operations to keep the website running fast.
|||>> SELECT "log record" FROM ::fn_dblog(null,null)
>> All we need to know is who made the modifications, when, in which tables and what are the new values.
"Who" is not available on a log record by log record basis. It is not part of that binary data in most cases. There are some few records that contain a "who" such as BEGIN TRAN log records. This is included in other output columns of fn_dblog().
When is not available on a log record by log record basis. There are some few record types that contain a "when" such as BEGIN TRAN and END TRAN log records. These are included as other columns in fn_dblog().
Which table is not actually stored in the log record in SQL 2005 and later. This is due to partitioning. The partition has to be linked through the catalog metadata back to its base table and index. This is attempted by fn_dblog() itself and shows up as other columns in the output. DDL can make this lookup fail.
"New values" are often just a byte by byte binary diff of the old row from the new row, not the full values themselves. The log record code does not actually know how to crack the row binary data, it just passes it along to other components in the system. i.e., if you update a INT column from a value of 1 to a value of 257, we may only log a single byte 0x01 as the difference.
The SQL 2005 output for fn_dblog() has been supplemented to try to make some of this easier, but the reality is that some of what you want is just not in the log in many cases.
Thanks Peter for this interesting complement of information.
We actually take care of the "When" and the "Who" because each table of our database contain an updatedBy and updatedDt column. These columns are systematicly updated on each changes by the application layer. We only need to find the new values of the modification.
For the byte by byte binary diff, I guess that you are talking about the online transaction log because taking a closer look at the transaction log backup file (.trn) indicates that new values are stored in the file. I've opened it with an hex editor and I was able to see the new inserted values.
Thursday, March 8, 2012
Auditing a table for SQL Server
Basically what I have to do is, I need to log all record deletions from a particular table. I've been looking through SQL Profiler, but so far I haven't been able to figure out how to do this.
Any help would be greatly appreciated.
Thanks.Best way would probably be to implement a trigger on the table that inserts the deleted record into a backup table, alnog with the date it was deleted. This table would have to get purged every once in a while, in order to make sure that it itself does not become larger than the table you are auditing, though. Hope this helps.|||Or add buisness logic. On our 'user' table, we shut them off with a datetime column, rather than delete them, for example.|||If you can afford then use Lumigent's (http://www.lumigent.com) ENTEGRA which is best used tool to audit the database events at all levels.
Sunday, February 19, 2012
Attempt to fetch logical page error
I have recently moved some packages I had been working on from my development to production environment. Having come across many configuration related errors, I believed my latest one to be of this type. However I'm recieving one I've never seen before:
"Attempt to fetch logical page (1:95152) in database 8 failed. It belongs to allocation unit 72057594043301888 not to 72057594045661184.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly"
This package works fine on the development db, however I don't even know where to start tracking this issue down. Any thoughts?
Thanks,
Adrian CrawfordI just googled that message and got a link to an article by Bob Dorr who works for PSS supporting SQL Server.
In other words - I suspect this is a SQL Server engine problem, not a SSIS one.
-Jamie|||This sounds like you have a database problem. If it is SQL Server then you should probably post this to the relational engine forum. Again if this is SQL Server, you might try running DBCC on the database to see if that shows any problems.
Matt|||Thanks for the responses, I'll see if anyone knows about this in the database engine forum.
Adrian
Attempt to fetch logical page error
I have recently moved some dts packages I had been working on from my development(sql2k5) to production environment(sql2k5). Having come across many configuration related errors, I believed my latest one to be of this type at first. However I'm recieving one I've never seen before:
"Attempt to fetch logical page (1:95152) in database 8 failed. It belongs to allocation unit 72057594043301888 not to 72057594045661184.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly"
This package works fine on the development db, however I don't even know where to start tracking this issue down. Any thoughts? I have tried the SSIS forum and they believe it to be a db engine issue.
Thanks,
Adrian CrawfordThere was a low-level problem with one of my tables involved in the dts on production. I found the specific table by running DBCC checkdb. At that point I dropped and recreated the table which has fixed the problem.
Adrian
Thursday, February 16, 2012
Attaching Databases
I've obtained a copy of the PRODUCTION database for restoring on the TEST
Environment. By detaching them and copying the underlying files. Not my
preferred approach, but the one I'm stuck with.
When I attach them into the TEST environment. They register to the instance
as READ-ONLY. When I try to take them out of READ-ONLY mode, the error with
5105 Error. Unable to activate device.
The devices are there and the permissions / attributes for the file are OK.
Any ideas?Beverley, one thing to look at... maybe the database you
got the mdf/ndf/ldf files from, was marked read only?
and ALSO thr mdf/ndf/ldf files were marked read only at
the file level (ATTRIB command). Both are done to
improve performance, but you'd need to get BOTH the files
and the database out of read-only status... You can do it
in the Windows Explorer attributes of the file or the DOS
ATTRIB command... Bruce
>--Original Message--
>Hi
>I've obtained a copy of the PRODUCTION database for
restoring on the TEST
>Environment. By detaching them and copying the
underlying files. Not my
>preferred approach, but the one I'm stuck with.
>When I attach them into the TEST environment. They
register to the instance
>as READ-ONLY. When I try to take them out of READ-ONLY
mode, the error with
>5105 Error. Unable to activate device.
>The devices are there and the permissions / attributes
for the file are OK.
>Any ideas?
>.
>
Thursday, February 9, 2012
Attach without Detach?
another server and then attach the database without detaching the database
from production? I was thinking this might replace the copying of the .BAK
and the restore.
Thanks.
Ron
Mostly it will work, but might not as reliable as first detach. Also, the
backup and restore leaves you another running db.
"Ron" <Ron@.discussions.microsoft.com> wrote in message
news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> Is it possible to copy the .mdf and .ldf files from a production server to
> another server and then attach the database without detaching the database
> from production? I was thinking this might replace the copying of the
> .BAK
> and the restore.
> Thanks.
> Ron
|||That is a good way if you don't care about the integrity of your
database<g>. Seriously you should never simply copy the files. It only
takes a second to issue the detach and it will be done right. If you can't
take it offline then do a full backup instead.
Andrew J. Kelly SQL MVP
"Ron" <Ron@.discussions.microsoft.com> wrote in message
news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> Is it possible to copy the .mdf and .ldf files from a production server to
> another server and then attach the database without detaching the database
> from production? I was thinking this might replace the copying of the
> .BAK
> and the restore.
> Thanks.
> Ron
|||If one database is live on server, you can not copy its physical files.. this
will lead into file sharing voilation. Before copying files to another
location you must have to detach a database first.
"sql question" wrote:
> Mostly it will work, but might not as reliable as first detach. Also, the
> backup and restore leaves you another running db.
> "Ron" <Ron@.discussions.microsoft.com> wrote in message
> news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
>
>
|||Thank You for the replies
"Deepakontheweb" wrote:
[vbcol=seagreen]
> If one database is live on server, you can not copy its physical files.. this
> will lead into file sharing voilation. Before copying files to another
> location you must have to detach a database first.
>
>
> "sql question" wrote:
Attach without Detach?
another server and then attach the database without detaching the database
from production? I was thinking this might replace the copying of the .BAK
and the restore.
Thanks.
RonMostly it will work, but might not as reliable as first detach. Also, the
backup and restore leaves you another running db.
"Ron" <Ron@.discussions.microsoft.com> wrote in message
news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> Is it possible to copy the .mdf and .ldf files from a production server to
> another server and then attach the database without detaching the database
> from production? I was thinking this might replace the copying of the
> .BAK
> and the restore.
> Thanks.
> Ron|||That is a good way if you don't care about the integrity of your
database<g>. Seriously you should never simply copy the files. It only
takes a second to issue the detach and it will be done right. If you can't
take it offline then do a full backup instead.
--
Andrew J. Kelly SQL MVP
"Ron" <Ron@.discussions.microsoft.com> wrote in message
news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> Is it possible to copy the .mdf and .ldf files from a production server to
> another server and then attach the database without detaching the database
> from production? I was thinking this might replace the copying of the
> .BAK
> and the restore.
> Thanks.
> Ron|||If one database is live on server, you can not copy its physical files.. this
will lead into file sharing voilation. Before copying files to another
location you must have to detach a database first.
"sql question" wrote:
> Mostly it will work, but might not as reliable as first detach. Also, the
> backup and restore leaves you another running db.
> "Ron" <Ron@.discussions.microsoft.com> wrote in message
> news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> > Is it possible to copy the .mdf and .ldf files from a production server to
> > another server and then attach the database without detaching the database
> > from production? I was thinking this might replace the copying of the
> > .BAK
> > and the restore.
> >
> > Thanks.
> >
> > Ron
>
>|||Thank You for the replies
"Deepakontheweb" wrote:
> If one database is live on server, you can not copy its physical files.. this
> will lead into file sharing voilation. Before copying files to another
> location you must have to detach a database first.
>
>
> "sql question" wrote:
> > Mostly it will work, but might not as reliable as first detach. Also, the
> > backup and restore leaves you another running db.
> >
> > "Ron" <Ron@.discussions.microsoft.com> wrote in message
> > news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> > > Is it possible to copy the .mdf and .ldf files from a production server to
> > > another server and then attach the database without detaching the database
> > > from production? I was thinking this might replace the copying of the
> > > .BAK
> > > and the restore.
> > >
> > > Thanks.
> > >
> > > Ron
> >
> >
> >
Attach without Detach?
another server and then attach the database without detaching the database
from production? I was thinking this might replace the copying of the .BAK
and the restore.
Thanks.
RonMostly it will work, but might not as reliable as first detach. Also, the
backup and restore leaves you another running db.
"Ron" <Ron@.discussions.microsoft.com> wrote in message
news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> Is it possible to copy the .mdf and .ldf files from a production server to
> another server and then attach the database without detaching the database
> from production? I was thinking this might replace the copying of the
> .BAK
> and the restore.
> Thanks.
> Ron|||That is a good way if you don't care about the integrity of your
database<g>. Seriously you should never simply copy the files. It only
takes a second to issue the detach and it will be done right. If you can't
take it offline then do a full backup instead.
Andrew J. Kelly SQL MVP
"Ron" <Ron@.discussions.microsoft.com> wrote in message
news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
> Is it possible to copy the .mdf and .ldf files from a production server to
> another server and then attach the database without detaching the database
> from production? I was thinking this might replace the copying of the
> .BAK
> and the restore.
> Thanks.
> Ron|||If one database is live on server, you can not copy its physical files.. thi
s
will lead into file sharing voilation. Before copying files to another
location you must have to detach a database first.
"sql question" wrote:
> Mostly it will work, but might not as reliable as first detach. Also, the
> backup and restore leaves you another running db.
> "Ron" <Ron@.discussions.microsoft.com> wrote in message
> news:967A02D0-F523-45F9-9817-A325262DAB79@.microsoft.com...
>
>|||Thank You for the replies
"Deepakontheweb" wrote:
[vbcol=seagreen]
> If one database is live on server, you can not copy its physical files.. t
his
> will lead into file sharing voilation. Before copying files to another
> location you must have to detach a database first.
>
>
> "sql question" wrote:
>