Sql-server – bulk insert from file

bulkimportsql servert-sql

I am often requested to upload data from file (let's say csv) into a Sql Server 2008 db.

I would like to use BULK INSERT, but I have no access to the db server file system.

Questions

  • is there a way to pass/upload a remote file to the Sql Server in order to use the BULK INSERT?

  • is there any other tsql way to import data from file to db?

Best Answer

If you have one of the system administrators or database administrators create a read/write share on the server and grant your domain account access to the share, then you should be able to copy the data up and then use BULK INSERT because it would run in the context of the SQL Server service account which would be able to see the path. Alternatively, you could make a request that they place the data file on the server for you and give you the local path which you would then use in your BULK INSERT script.

You could also use the SQL Server Import/Export wizard to create a connection to your file as the source on your workstation then create a connection to the server as the destination and import the file that way. You can get to the Import/Export wizard by right clicking the database in Object Explorer and selecting Tasks > Import Data.