如何查看交易日志? [英] How to view transaction logs?

查看:48
本文介绍了如何查看交易日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定事务日志是我需要的还是什么.

I am not sure if the transaction log is what I need or what.

我的第一个问题是我有一个插入一些行的存储过程.我刚刚检查了 elmah,我看到发生了一些 sql 异常.它们都是相同的错误(违反了 PK 约束).

My first problem is that I have a stored procedure that inserts some rows. I was just checking out elmah and I see that some sql exceptions happens. They all are the same error(a PK constraint was violated).

除此之外,elmah 并没有告诉我更多.所以我不知道是哪一行导致了这个主键约束(我猜同一行由于某种原因被添加了两次).

Other than that elmah is not telling me much more. So I don't know what row caused this primary key constraint(I am guessing the same row was for some reason being added twice).

所以我不确定事务日志是否会告诉我发生了什么以及尝试插入哪些数据.我无法重现这个错误,它总是对我有用.

So I am not sure if the the transaction log would tell me what happened and what data was trying to be inserted. I can't recreate this error it always works for me.

我的第二个问题是由于某种原因,当我的页面加载时,我认为该数据库中的一行不再存在(我有一个带有 PK 的隐藏列.)当我尝试找到这个主时key 数据库中不存在.

My second problem is for some reason when my page loads up I have a row from that database that I don't think exists anymore(I have a hidden column with the PK in it.) When I try to find this primary key it does not exist in the database.

我使用的是 ms sql 2005.

I am using ms sql 2005.

谢谢

推荐答案

我认为事务日志对您没有帮助.

I don't think transaction log will help you.

关于如何插入违反唯一性数据的 SQL 2 模式.有一个设置:IGNORE_DUP_KEY.默认情况下它是关闭的.如果您将其打开,SQL 将忽略重复的行并且您的 INSERT 语句将成功.

SQL 2 modes on how to insert data with uniqueness violation. There is a setting : IGNORE_DUP_KEY. By default it is OFF. IF you turn it ON, SQL will ignire duplicate rows and your INSERT statement will succeed.

你可以在这里阅读它:http://msdn.microsoft.com/en-us/library/ms175132.aspx

顺便说一句,要查看事务日志,可以使用以下命令:

BTW, to view transaction log, you can use this command:

SELECT * FROM  fn_dblog(null, null)

这篇关于如何查看交易日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆