Bulk Insert
BULK
INSERT
CSVTest
FROM
'F:\wrk.xlsx'
WITH
(
FIELDTERMINATOR
= ',',
ROWTERMINATOR
= '\n'
)
GO
when am trying to execute this getting an error like Cannot bulk load because the file "F:\wrk.xlsx" could not be opened. Operating system error code 32(failed to retrieve text for this error.
Reason: 15105). can anyone help me regarding this.................
May 4th, 2011 3:25am
OS Error 32 occurs when file is already opened by other process..
Can you check if it the excel file is already opened..- Vishal
SqlAndMe.com
Free Windows Admin Tool Kit Click here and download it now
May 4th, 2011 4:52am
Again am getting an error like Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 1 .
May 4th, 2011 5:06am
Perhaps you can use OPENDATASOURCE command
SELECT *
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
'Data Source="c:\MyExcel.xls";
User ID=Admin;Password=;Extended properties=Excel 8.0')...Book1$
Below script works for me
CREATE TABLE TmpStList
(
stFName varchar (10) NOT NULL,
stLName varchar (10) NOT NULL,
stEmail varchar (30) NOT NULL
)
go
The data file (hawk.dat):
"Kelly","Reynold","kelly@reynold.com"
"John","Smith","bill@smith.com"
"Sara","Parker","sara@parker.com"
The format file (hawk.bcp):
8.0
4
1 SQLCHAR 0 1 "\"" 0 first_quote ""
2 SQLCHAR 0 10 "\",\"" 1 stFName ""
3 SQLCHAR 0 10 "\",\"" 2 stLName ""
4 SQLCHAR 0 30 "\"\r\n" 3 stEmail ""
bulk insert TmpStList from 'C:\hawk.dat'
with (formatfile = 'C:\hawk.bcp')
select * from TmpStListBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
Free Windows Admin Tool Kit Click here and download it now
May 4th, 2011 5:11am