SQL Server无法从生成的脚本导入 - 语法错误接近命令''''

时间:2016-07-07 18:12:13

标签: sql-server sqlcmd

我正在使用SQL Server for SQL Server 2012中生成的.sql文件,以便在另一台服务器(SQL Server 2012)上构建和填充数据库。

当我尝试使用sqlcmd执行查询文件时,出现单引号问题时出现错误。

错误是:

  

Sqlcmd:错误:命令'''附近的第45632行语法错误在文件' db_main.sql'。

insert命令是:

INSERT [dbo].[SharedFields] ([Id], [ItemId], [FieldId], [Value], [Created], [Updated], [DAC_Index]) VALUES (N'jjjjjjjjjjjjjj', N'kkkkkkkkkkkkkkk', N'llllllllllllllllllll', N'<p>ItemIdPlaceholder</p>', CAST(N'2016-03-02T16:22:55.417' AS DateTime), CAST(N'2016-03-02T16:22:55.417' AS DateTime), NULL)
INSERT [dbo].[SharedFields] ([Id], [ItemId], [FieldId], [Value], [Created], [Updated], [DAC_Index]) 
VALUES (N'aaaaaaaaa', N'bbbbbbbbb', N'cccccccccc', N'</div>
<script>
(function ($) {
    $j(''.wp-post-image'').each(function () {
        var postImage = $j(this);
        if (postImage.attr(''src'').indexOf(''/~/icon/'') == 0 || postImage.attr(''src'').indexOf(window.IconsCacheFolder) == 0) {
          postImage.addClass(''smallIcon'');
        }
    });

  var langs = $(''.evaluateLanguage'');  //error occurs here!

  for (var i = 0; i < langs.length; ++i) {
    var textToPrint = '''';
    var splitLang = $(langs[i]).text().split(''^'');
    for (var j = 0; j < splitLang.length; j++) {
      if (splitLang[j].split(''|'')[0] != '''') {
        textToPrint += "<a class=\"languageLink\" href=\"\" onclick=\"event.stopPropagation();scForm.getParentForm().postRequest('''','''','''',''contenteditor:launchtab(id=" + $j(''.idFilter'').eq(i).text() + ", la=" + splitLang[j].split(''|'')[0] + ", version=1)''); return false;\"><span class=\"languageSpan\">" + splitLang[j].split(''|'')[0] + "</span></a>";
      }
      langs.eq(i).html(textToPrint);
    }
  }
})(jQuery || $j)
</script>', CAST(N'2016-03-02T16:22:55.427' AS DateTime), CAST(N'2016-03-02T16:22:55.427' AS DateTime), NULL)
INSERT [dbo].[SharedFields] ([Id], [ItemId], [FieldId], [Value], [Created], [Updated], [DAC_Index]) VALUES (N'eeeeeeeeeeeeeeee', N'ffffffffffff', N'gggggggggggggg', N'<div class="mainmargin" id="grid-content" style="position: relative; width: 100%;overflow-x: hidden; overflow-y: hidden;">', CAST(N'2016-03-02T16:22:55.427' AS DateTime), CAST(N'2016-03-02T16:22:55.427' AS DateTime), NULL)

我们已经插入并解析了&#39;它在SQL Server 2012中解析得很好 - 没有错误/成功完成。

我们的问题是:为什么插件本身工作正常,但是当它是较大查询的一部分时会失败?

.sql文件大小为128 MB。

0 个答案:

没有答案