我想对通过Stream获得的数据执行批量插入。在这里,我获得了调查数据,其中每一行都是一个人的信息和答案。我通过.net消耗了流,并逐行保存了以vblf结尾的数据(我通过Word检查了它是否存在,并且可以看到每个数据集之后都有一个新行)。数据以逗号分隔。首先,我创建了一个包含1000列的表,因为我尚不知道会输入多少数据,但可以肯定的是,数据集的长度不会超过500,即使将来将来也肯定不会超过1000,如果是的话,我可以延长桌子。这是我创建的表:
前两个数据集如下:
"4482359","12526","2014 Company","upload by","new upload","Anonymous","User","anonymous@company.org","","222.222.222.222","1449772662000","undefined","","951071","2015","","2","3","1","5","1","1","3","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","5","1","3","3","3","3","1","2","3","1","3","5","1","","Here ppl can type in some text.","1"
"4482360","12526","2014 Company","upload by","new upload","Anonymous","User","anonymous@company.org","","222.222.222.222","1449772662000","undefined","","951071","2015","","2","5","1","","2","2","3","4","3","1","4","4","4","4","3","3","","4","3","1","4","3","1","4","4","4","3","3","4","4","4","4","3","4","4","4","4","4","4","5","2","3","4","1","3","2","2","5","1","3","","2","","","2"
现在,我要使用此命令进行批量插入:
USE MyDatabase
BULK INSERT insert_Table FROM 'C:\new.txt'
With (FIRSTROW = 2, FIELDTERMINATOR = ',', ROWTERMINATOR = '\n')
该命令运行并没有引发错误,但是我收到消息0 rows affected
,并且数据表中没有数据。有人知道我在这里做错了吗?