I am creating a excel file 开发者_开发技巧using bcp command/xp_cmdshell in SQL Server 2005.
select @bcpquery =
'bcp "SELECT Column1 FROM Tablename" queryout '+
@fullFileName +' -c -t -U<username> -P<password> -S'+ @@servername
And I am not able to read the excel data using below statement
SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=<PATH\filename.xls>;HDR=YES',
'SELECT * FROM [sheetname$]')
I am not able to read file, I believe this is happening due to unicode characters.
Could anybody help me?
It appears are though you're using BCP to copy the data out as a delimited file, whereas the OPENROWSET call is reading an Excel sheet. Excel is very forgiving when openings a CSV as XLS, but I have no idea if the Jet driver is the same way.
I would suggest using either BULK INSERT to read the delimited file, or ideally SSIS to both export AND import the data.
精彩评论