我有一个大小约为20 GB的数据库。我为数据库和内容生成了脚本,现在尝试导入到不同的服务器。我用Google搜索并发现了这样的事情:
sqlcmd -S localhost -i C:\Users\Administrator\Downloads\SQL_backup.sql
在执行这样的sqlcmd
时,流程开始但过了一段时间我收到错误:
Msg 105,Level 15,State 1,Server WIN-I79PRE6OQTV,Line 793
字符串后的未闭合引号' 172551665 ......
所以我的问题是 - 如果我使用Microsoft SQL Server Management Studio生成脚本 - 为什么导入数据时会出现这样的错误?
如何解决此问题?
P.S此错误所抱怨的列包含以字符串形式存储的XML数据,并且是非常长的字符串。
还有其他备份/恢复方式吗?
已更新
我跑了 - > dbcc checkdb(' CreditInfoDB',REPAIR_ALLOW_DATA_LOSS)
这是结果
DBCC results for 'CreditInfoDB'.
Service Broker Msg 9675, State 1: Message Types analyzed: 14.
Service Broker Msg 9676, State 1: Service Contracts analyzed: 6.
Service Broker Msg 9667, State 1: Services analyzed: 3.
Service Broker Msg 9668, State 1: Service Queues analyzed: 3.
Service Broker Msg 9669, State 1: Conversation Endpoints analyzed: 0.
Service Broker Msg 9674, State 1: Conversation Groups analyzed: 0.
Service Broker Msg 9670, State 1: Remote Service Bindings analyzed: 0.
Service Broker Msg 9605, State 1: Conversation Priorities analyzed: 0.
DBCC results for 'sys.sysrscols'.
There are 1092 rows in 14 pages for object "sys.sysrscols".
DBCC results for 'sys.sysrowsets'.
There are 147 rows in 3 pages for object "sys.sysrowsets".
DBCC results for 'sys.sysclones'.
There are 0 rows in 0 pages for object "sys.sysclones".
DBCC results for 'sys.sysallocunits'.
There are 172 rows in 2 pages for object "sys.sysallocunits".
DBCC results for 'sys.sysfiles1'.
There are 2 rows in 1 pages for object "sys.sysfiles1".
DBCC results for 'sys.sysseobjvalues'.
There are 0 rows in 0 pages for object "sys.sysseobjvalues".
DBCC results for 'sys.syspriorities'.
There are 0 rows in 0 pages for object "sys.syspriorities".
DBCC results for 'sys.sysdbfrag'.
There are 0 rows in 0 pages for object "sys.sysdbfrag".
DBCC results for 'sys.sysfgfrag'.
There are 0 rows in 0 pages for object "sys.sysfgfrag".
DBCC results for 'sys.sysdbfiles'.
There are 2 rows in 1 pages for object "sys.sysdbfiles".
DBCC results for 'sys.syspru'.
There are 0 rows in 0 pages for object "sys.syspru".
DBCC results for 'sys.sysbrickfiles'.
There are 0 rows in 0 pages for object "sys.sysbrickfiles".
DBCC results for 'sys.sysphfg'.
There are 1 rows in 1 pages for object "sys.sysphfg".
DBCC results for 'sys.sysprufiles'.
There are 2 rows in 1 pages for object "sys.sysprufiles".
DBCC results for 'sys.sysftinds'.
There are 0 rows in 0 pages for object "sys.sysftinds".
DBCC results for 'sys.sysowners'.
There are 14 rows in 1 pages for object "sys.sysowners".
DBCC results for 'sys.sysdbreg'.
There are 0 rows in 0 pages for object "sys.sysdbreg".
DBCC results for 'sys.sysprivs'.
There are 141 rows in 1 pages for object "sys.sysprivs".
DBCC results for 'sys.sysschobjs'.
There are 2271 rows in 52 pages for object "sys.sysschobjs".
DBCC results for 'sys.syscsrowgroups'.
There are 0 rows in 0 pages for object "sys.syscsrowgroups".
DBCC results for 'sys.sysexttables'.
There are 0 rows in 0 pages for object "sys.sysexttables".
DBCC results for 'sys.syscolpars'.
There are 890 rows in 14 pages for object "sys.syscolpars".
DBCC results for 'sys.sysxlgns'.
There are 0 rows in 0 pages for object "sys.sysxlgns".
DBCC results for 'sys.sysxsrvs'.
There are 0 rows in 0 pages for object "sys.sysxsrvs".
DBCC results for 'sys.sysnsobjs'.
There are 1 rows in 1 pages for object "sys.sysnsobjs".
DBCC results for 'sys.sysusermsgs'.
There are 0 rows in 0 pages for object "sys.sysusermsgs".
DBCC results for 'sys.syscerts'.
There are 0 rows in 0 pages for object "sys.syscerts".
DBCC results for 'sys.sysrmtlgns'.
There are 0 rows in 0 pages for object "sys.sysrmtlgns".
DBCC results for 'sys.syslnklgns'.
There are 0 rows in 0 pages for object "sys.syslnklgns".
DBCC results for 'sys.sysxprops'.
There are 0 rows in 0 pages for object "sys.sysxprops".
DBCC results for 'sys.sysscalartypes'.
There are 34 rows in 1 pages for object "sys.sysscalartypes".
DBCC results for 'sys.systypedsubobjs'.
There are 0 rows in 0 pages for object "sys.systypedsubobjs".
DBCC results for 'sys.sysidxstats'.
There are 227 rows in 4 pages for object "sys.sysidxstats".
DBCC results for 'sys.sysiscols'.
There are 419 rows in 2 pages for object "sys.sysiscols".
DBCC results for 'sys.sysendpts'.
There are 0 rows in 0 pages for object "sys.sysendpts".
DBCC results for 'sys.syswebmethods'.
There are 0 rows in 0 pages for object "sys.syswebmethods".
DBCC results for 'sys.sysbinobjs'.
There are 23 rows in 1 pages for object "sys.sysbinobjs".
DBCC results for 'sys.sysaudacts'.
There are 0 rows in 0 pages for object "sys.sysaudacts".
DBCC results for 'sys.sysobjvalues'.
There are 234 rows in 22 pages for object "sys.sysobjvalues".
DBCC results for 'sys.syscscolsegments'.
There are 0 rows in 0 pages for object "sys.syscscolsegments".
DBCC results for 'sys.syscsdictionaries'.
There are 0 rows in 0 pages for object "sys.syscsdictionaries".
DBCC results for 'sys.sysclsobjs'.
There are 16 rows in 1 pages for object "sys.sysclsobjs".
DBCC results for 'sys.sysrowsetrefs'.
There are 0 rows in 0 pages for object "sys.sysrowsetrefs".
DBCC results for 'sys.sysremsvcbinds'.
There are 0 rows in 0 pages for object "sys.sysremsvcbinds".
DBCC results for 'sys.sysxmitqueue'.
There are 0 rows in 0 pages for object "sys.sysxmitqueue".
DBCC results for 'sys.sysrts'.
There are 0 rows in 0 pages for object "sys.syscommittab".
DBCC results for 'sys.filetable_updates_2105058535'.
There are 0 rows in 0 pages for object "sys.filetable_updates_2105058535".
CHECKDB found 0 allocation errors and 0 consistency errors in database 'CreditInfoDB'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
答案 0 :(得分:0)
您可以而且应该使用ETL备份到文件并将其导入新服务器。 ETL将比大型数据集的脚本更有效。
Microsoft提供SSIS来做这件事。您可以导出到RAW文件(不要通过CSV或XLSX选项),并将其导入另一台服务器。
答案 1 :(得分:0)
您的脚本文件更有可能在此过程中的某个时刻被截断。解析器具有文件大小限制(您正在使用多个进程[创建,加载,执行等])。
编辑:根据OP的评论,添加信息。
如果数据已损坏,那么您采用的方法没有区别。至于想要一个新的数据库,那么;我们的想法是恢复为新数据库,而不是覆盖旧数据库。
在进行备份运行之前,对源数据库进行完整性检查。备份后;验证您的备份媒体。
答案 2 :(得分:0)
您是否尝试增加数据包大小并查看错误是否消失或是否出现其他错误?
sqlcmd -S localhost -a 32767 -i C:\Users\Administrator\Downloads\SQL_backup.sql
答案 3 :(得分:0)
除了运行备份/恢复之外,您还可以尝试按原样移动数据库,方法是分离数据库,然后将其重新连接到新位置或使用移动数据库。
这两种方法都包含在msdn 和Detach MsSQL database 2008 - 2016上(我通常不会发布链接,但这可以直接来自官方支持网站,所以应该站起来几年)