r/DatabaseHelp • u/marcus13345 • Sep 17 '15
On uploading CSV data to SQL
After searching around on the subject, i found everyone uses the local filesystem and does a bulk insert. As much as i would like to jump on that bandwagon, at my work we don't have access to the local filesystem; only the database. Am i missing something that allows uploads into the filesystem via SQL? or does everyone else also have an FTP set up?
2
Upvotes
View all comments
Show parent comment
1
u/WhippingStar Sep 17 '15 edited Sep 17 '15
Yes, you would (how much depends on a number of things). However inserts this way means that if one row causes an error, the entire transaction will fail (or at least the current batch) because it is one insert statement , so it is an all or nothing operation.
EDIT:
So if you have MSSQL 2008 or later you can contruct an insert as follows:
INSERT INTO MyTable (Name, ID)
VALUES ('First',1),
('Second',2),
('Third',3),
('Fourth',4),
('Fifth',5)
EDIT-EDIT: I wasn't sure from your original post that you meant MS SQL Server, but since it appears that's what you are using, BCP can load to a remote server and will be the fastest way to load a file.