• <i id='RAIJq'><tr id='RAIJq'><dt id='RAIJq'><q id='RAIJq'><span id='RAIJq'><b id='RAIJq'><form id='RAIJq'><ins id='RAIJq'></ins><ul id='RAIJq'></ul><sub id='RAIJq'></sub></form><legend id='RAIJq'></legend><bdo id='RAIJq'><pre id='RAIJq'><center id='RAIJq'></center></pre></bdo></b><th id='RAIJq'></th></span></q></dt></tr></i><div id='RAIJq'><tfoot id='RAIJq'></tfoot><dl id='RAIJq'><fieldset id='RAIJq'></fieldset></dl></div>

  • <tfoot id='RAIJq'></tfoot>

  • <legend id='RAIJq'><style id='RAIJq'><dir id='RAIJq'><q id='RAIJq'></q></dir></style></legend>
      • <bdo id='RAIJq'></bdo><ul id='RAIJq'></ul>

      <small id='RAIJq'></small><noframes id='RAIJq'>

        带文件名参数的批量插入

        Bulk Insert with filename parameter(带文件名参数的批量插入)
          <legend id='P8esp'><style id='P8esp'><dir id='P8esp'><q id='P8esp'></q></dir></style></legend>
        1. <i id='P8esp'><tr id='P8esp'><dt id='P8esp'><q id='P8esp'><span id='P8esp'><b id='P8esp'><form id='P8esp'><ins id='P8esp'></ins><ul id='P8esp'></ul><sub id='P8esp'></sub></form><legend id='P8esp'></legend><bdo id='P8esp'><pre id='P8esp'><center id='P8esp'></center></pre></bdo></b><th id='P8esp'></th></span></q></dt></tr></i><div id='P8esp'><tfoot id='P8esp'></tfoot><dl id='P8esp'><fieldset id='P8esp'></fieldset></dl></div>

            <bdo id='P8esp'></bdo><ul id='P8esp'></ul>

            <small id='P8esp'></small><noframes id='P8esp'>

              <tbody id='P8esp'></tbody>
            <tfoot id='P8esp'></tfoot>

                • 本文介绍了带文件名参数的批量插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要将数千个数据文件加载到 SQL Server 表中.所以我写了一个只接收一个参数——文件名的存储过程.但是..以下不起作用..编译器"抱怨@FileName参数..它只想要纯字符串..像'file.txt'.提前致谢.

                  I need to load a couple of thousands of data files into SQL Server table. So I write a stored procedure that receives just one parameter - file name. But.. The following doesn't work.. The "compiler" complains on @FileName parameter.. It wants just plain string.. like 'file.txt'. Thanks in advance.

                  伊兰.

                  BULK INSERT TblValues
                  FROM @FileName
                  WITH 
                  (
                  FIELDTERMINATOR =',',
                  ROWTERMINATOR ='
                  '
                  )
                  

                  推荐答案

                  BULK INSERT 语句的语法是:

                  BULK INSERT 
                     [ database_name. [ schema_name ] . | schema_name. ] [ table_name | view_name ] 
                        FROM 'data_file' 
                       [ WITH 
                  

                  所以,文件名必须是字符串常量.要解决问题,请使用动态 SQL:

                  So, the file name must be a string constant. To solve the problem please use dynamic SQL:

                  DECLARE @sql NVARCHAR(4000) = 'BULK INSERT TblValues FROM ''' + @FileName + ''' WITH ( FIELDTERMINATOR ='','', ROWTERMINATOR =''
                  '' )';
                  EXEC(@sql);
                  

                  这篇关于带文件名参数的批量插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SQL query to group by day(按天分组的 SQL 查询)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                  sql group by versus distinct(sql group by 与不同)
                  How to return a incremental group number per group in SQL(如何在SQL中返回每个组的增量组号)
                  Count number of records returned by group by(统计分组返回的记录数)
                  SQL GROUP BY CASE statement with aggregate function(带聚合函数的 SQL GROUP BY CASE 语句)

                    • <bdo id='wUic4'></bdo><ul id='wUic4'></ul>

                      1. <tfoot id='wUic4'></tfoot>

                          • <i id='wUic4'><tr id='wUic4'><dt id='wUic4'><q id='wUic4'><span id='wUic4'><b id='wUic4'><form id='wUic4'><ins id='wUic4'></ins><ul id='wUic4'></ul><sub id='wUic4'></sub></form><legend id='wUic4'></legend><bdo id='wUic4'><pre id='wUic4'><center id='wUic4'></center></pre></bdo></b><th id='wUic4'></th></span></q></dt></tr></i><div id='wUic4'><tfoot id='wUic4'></tfoot><dl id='wUic4'><fieldset id='wUic4'></fieldset></dl></div>
                              <tbody id='wUic4'></tbody>
                            <legend id='wUic4'><style id='wUic4'><dir id='wUic4'><q id='wUic4'></q></dir></style></legend>

                            <small id='wUic4'></small><noframes id='wUic4'>