【问题标题】:Generate SQL script from excel sheet从 Excel 工作表生成 SQL 脚本
【发布时间】:2019-03-03 15:37:40
【问题描述】:

我正在尝试从 Excel 工作表创建一个 sql 脚本。这应该会自动插入单元格的值。我尝试如下,但 Excel 不例外:

="INSERT INTO taSwitchFilter VALUES('"&A2&"','111','1','"&B3&"','"<properties actionContext="After"><rule type="SwitchRequestType"><switchRequestType type="List Event PGM" /></rule><rule type="Source"><source type="Logical"><logical name="&B3&" /></source></rule></properties>','69')"'

谁能帮我纠正这个问题。我想我很接近了。

【问题讨论】:

    标签: sql excel xml


    【解决方案1】:

    您遇到的第一个错误从小于号开始从这一点开始,excel 不知道该怎么做,因为它不再是文本

    ="INSERT INTO taSwitchFilter VALUES('"&A2&"','111','1','"&B3&"','"
    

    由于无法与您进行完整的对话,因此做出有根据的猜测,我认为您的公式应该是这样的

    ="INSERT INTO taSwitchFilter VALUES('"&A2&"','111','1','"&B3&"','<properties actionContext=""After""><rule type=""SwitchRequestType""><switchRequestType type=""List Event PGM"" /></rule><rule type=""Source""><source type=""Logical""><logical name=" &B3& " /></source></rule></properties>','69')"
    

    请注意,如果您想在输出中包含引号字符,您实际上需要放置两个引号字符,或者使用 & CHAR(34)& 作为引号字符。

    这些长公式的诀窍是慢慢分解公式,而不是一口气完成。 祝你好运,希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-02
      • 2011-06-07
      相关资源
      最近更新 更多