gpt4 book ai didi

sql-server - 在 MS SQL Server 生成的 .sql 文件上解决 'Unclosed quotation mark after the character string'

转载 作者:行者123 更新时间:2023-12-03 20:18:37 25 4
gpt4 key购买 nike

我正在尝试在本地 SQL Server 安装上重新创建远程数据库。我有一个从远程数据库 SSMS 生成的 ~(6GB) .sql 文件,我在本地使用 sqlcmd 尝试导入。

这是我正在使用的命令:

sqlcmd -S SERVER -a 32000 -i inputfile.sql -o output.txt

其中大约 2200 条记录给了我: Unclosed quotation mark after the character string
我可以对导入设置(甚至创建一个新的导出 .sql 文件)做些什么来解决这个问题?非常奇怪的是,服务器生成的 sql 似乎不是有效的 sql。

最佳答案

Stackoverflow thread will prove useful for you .相关细节重新创建如下:

问题描述:

In some rare cases the sqlcmd utility can fail with the import and raise the following error: "Unclosed quotation mark after the character string ..." which indicates that one of SQL queries has not been executed. This happens because sqlcmd works using stream processing, i.e. it reads some piece of data, processes it, reads next piece and so on. In some cases an input file can contain huge SQL instruction which size is bigger than the amount of the data that could be processed by sqlcmd at a time, so sqlcmd tries to execute broken SQL and fails.



可能的解决方案

The sqlcmd utility can accept the "-a" parameter which defines the maximum size of packet (piece of data) that will be used during processing. The maximum value is 32767, the default value is 4096, so it makes sense to always use this parameter with maximum value.


sqlcmd -i input.sql -a 32767 -o import_log.txt

替代解决方案

如果上述方法对您来说失败了,您可能需要考虑使用批量复制 (BCP) 实用程序。我相信这是目前将数据从远程源移动到本地克隆的最快方法,反之亦然。您可以在此处找到更多详细信息: https://blogs.msdn.microsoft.com/sqlcat/2010/07/30/loading-data-to-sql-azure-the-fast-way/
bcp AdventureWorksLTAZ2008R2.SalesLT.Customer out C:\Users\user\Documents\GetDataFromSQLAzure.txt -c -U username@servername -S tcp:servername.database.windows.net -P password

关于sql-server - 在 MS SQL Server 生成的 .sql 文件上解决 'Unclosed quotation mark after the character string',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36507822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com