简体   繁体   中英

java - sqlserverbulkcopy-export to CSV

I have a requirement like read bulk data from sql server database through java and write to CSV. Have to use the same CSV to import the data into database.Is there an option with sqlserverbulkcopy class to generate CSV file? We can write plain java code to write CSV,but I may have huge data. I see that there is an option to read from CSV and bulk copy to database.

Using the BULK INSERT statement we can insert bulk data into the database directly from a CSV file. The simplest version of the BULK INSERT query looks like that:

BULK INSERT dbo.TableForBulkData
FROM 'C:\BulkDataFile.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

Also, you can read more here: How do I use Java to read a .csv file and insert its data into SQL Server?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM