错误[42000] [Microsoft] [SQL Server Native Client 10.0] [SQL Server] BACKUP日志 [英] ERROR [42000] [Microsoft][SQL Server Native Client 10.0][SQL Server]BACKUP Log

查看:4775
本文介绍了错误[42000] [Microsoft] [SQL Server Native Client 10.0] [SQL Server] BACKUP日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我正在使用sql server 2008.



hi I'm using sql server 2008.

con.Open()
           cmd = New OdbcCommand("DBCC SHRINKFILE(Legend_Log, 1)", con)
           cmd.ExecuteNonQuery()
           con.Close()
           con.Open()
           cmd = New OdbcCommand("BACKUP LOG Legend TO DISK=N'F:\full'", con)
           cmd.ExecuteNonQuery()
    i'm Getting below error on this line
       con.Close()
           con.Open()
           cmd = New OdbcCommand("DBCC SHRINKFILE(Legend, 1)", con)
           cmd.ExecuteNonQuery()
           con.Close()













ERROR [42000] [Microsoft][SQL Server Native Client 10.0][SQL Server]BACKUP LOG cannot be performed because there is no current database backup. ERROR [42000] [Microsoft][SQL Server Native Client 10.0][SQL Server]BACKUP LOG is terminating abnormally.





帮帮我修复



Help me to fix

推荐答案

您必须按正确的顺序备份数据;即:

- 备份数据库

- 备份日志文件(如果数据库处于完全恢复模式)

- 收缩日志(只有它的大小是疯狂的;否则不必要)



缩小尚未清空的日志文件是没有意义的。也不需要关闭并重新打开每个命令的连接。





原理上,这可能是这样的: br />
You have to backup your data in the right order; that is:
- Backup the database
- Backup the log file (if the database is in full recovery mode)
- Shrink the log (only if its size is insane; unnecessary otherwise)

There is no sense in shrinking a log file that has not been emptied yet. No need to close and reopen a connection at each command, too.


Schematically, that could be something like:
Dim result As Integer
con.Open()
cmd = New OdbcCommand("BACKUP DATABASE Legend TO DISK=N'F:\full'", con)
result = cmd.ExecuteNonQuery()
cmd.CommandText = "BACKUP LOG Legend_log TO DISK=N'F:\full'"
result = cmd.ExecuteNonQuery()
cmd.CommandText = "DBCC SHRINKFILE(Legend_log, 1)"
result = cmd.ExecuteNonQuery()
con.Close()





在这里你可以找到一些关于SQL Server备份的基础知识:

创建完整数据库备份(SQL Server) [ ^ ]


这篇关于错误[42000] [Microsoft] [SQL Server Native Client 10.0] [SQL Server] BACKUP日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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