I have a BULK INSERT
into a table but I need to add data that is not in my csv for the last column in each row of the table. For example, if my csv file contains 10 columns but the database table contains 11 columns, how can I add data for the last column? Modifying the csv file itself is not an option
Is this possible with BULK INSERT
?
Here is my script:
BULK INSERT [Data_GPS].[dbo].[Data_z]
FROM 'C:\TEMP\SQL\Bulk insert\dane.csv'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n',
ERRORFILE = 'C:\TEMP\SQL\Bulk insert\errors.txt',
TABLOCK
)
1条答案
按热度按时间js81xvg61#
Sure. Just use OPENROWSET(BULK ...) instead of BULK INSERT and you can add whatever extra columns you want. EG
But you have to create a format file for openrowset.