将存储过程结果导出到Excel工作表

时间:2011-11-09 04:08:50

标签: sql sql-server

Exporting stored procedure result to excel with column name

我查看了上面的链接并创建了存储过程。我没有将数据导入我在D:\ testing.xls和D:\ data_file.xls中创建的ExcelSheet

Errors List

1.usage: bcp {dbtable | query} {in | out | queryout | format} datafile
  [-m maxerrors]            [-f formatfile]          [-e errfile]
  [-F firstrow]             [-L lastrow]             [-b batchsize]
  [-n native type]          [-c character type]      [-w wide character type]
  [-N keep non-text native] [-V file format version] [-q quoted identifier]
  [-C code page specifier]  [-t field terminator]    [-r row terminator]
  [-i inputfile]            [-o outfile]             [-a packetsize]
  [-S server name]          [-U username]            [-P password]
  [-T trusted connection]   [-v version]             [-R regional enable]
  [-k keep null values]     [-E keep identity values]
  [-h "load hints"]
NULL

2.The system cannot find the file specified.
NULL

3.Could Not Find D:\data_file.xls
NULL

1 个答案:

答案 0 :(得分:0)

可能以下脚本对您有用。

INSERT INTO OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0','Data Source={\\Operations\Output\CR_20071130.xls};Extended Properties=Excel 8.0')..
[Sheet1$A1:H1] exec YourStoredProcedure