Unable to insert following Text.csv file which contains
ID,Address,Name,Subject
1,43-79,NYC, Aron , Works for IT,Networking
2, 43-89,CA ,Mike , Works for IT,Developer
How can i insert this data into SQL table(tabl1) which has ID,ADDRESS,NAME,SUBJECT column.
BULK
INSERT tabl1
FROM 'C:\Downloads\Test.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
If i use comma , i get an error.So how can i insert this data.
Your issue is due to the comma in the column value 'Works for IT,Networking' You can use Pipe symbol |
instead of comma.
Sample file will be like this.
1|43-79|NYC|Aron|Works for IT,Networking
2|43-89|CA|Mike|Works for IT,Developer
Sql Query
BULK
INSERT tabl1
FROM 'C:\Downloads\Test.csv'
WITH
(
DATAFILETYPE = 'char',
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
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.