Guys,
what particular drive/folder to stored the text/csv/excel file that the bulk insert will be reading? what if in my local drive is this applicable? or it should be in the shared folder in the server.
Thanks,
JOV
Guys,
what particular drive/folder to stored the text/csv/excel file that the bulk insert will be reading? what if in my local drive is this applicable? or it should be in the shared folder in the server.
Thanks,
JOV
For : BULK INSERT reads files from the SQL Server host, not from the client PC. If SQL Server is installed on your machine a local path (for example C:\data\file.csv) is fine. If the server is remote, put the file on the server itself or on a network share reachable by the server and reference it with a UNC path (for example \\server\share\file.csv).
The SQL Server service account (or the proxy account used by an Agent job) is the security context that opens the file. The Windows account used to connect with SSMS does not grant file access. Common problems are incorrect paths, missing read permissions for the SQL Server service account, or running SQL Server under a local system account that cannot access network shares. See the official BULK INSERT documentation for details and options: BULK INSERT (Transact-SQL).
BULK INSERT works with text files (CSV/TXT). It does not import native Excel .xls/.xlsx files directly. For Excel either save as CSV, use the Import Wizard/SSIS, or use OPENROWSET with the ACE OLE DB provider. See Microsoft guidance on importing Excel data: .
Quick example and tips:
BULK INSERT dbo.MyTable
FROM 'C:\Import\mydata.csv'
WITH (FIELDTERMINATOR = ',', ROWTERMINATOR = '\n', FIRSTROW = 2); If the file is on a developer PC and copying it to the server is not convenient, use the client-side bcp utility to push the file to the server instead. If errors say the file cannot be opened, verify the full path, grant read to the SQL Server service account, or move the file to a local folder on the database server. See the bcp docs for client-side import options: bcp Utility.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.