Bulk Insert into SQL Server from text file adding a uniqueidentifier, or skipping a column -
i need take rows text file , insert table. rows of file similar following:
string1 string2 string3 string4 ...
my table has 2 columns:
uniqueidentifier, stringvalue
i bulk insert table grabbing each row text file , adding new uniqueidentifier
each 1 (ideally guid, integer counter fine).
anyone have tip on how bulk upload? far sql is:
bulk insert tablenametoinsertinto 'c:\importlist.txt' ( rowterminator = '\n' ) go
try 1 -
values:
c:\importlist.txt -> string1 string2 string3 string4
format file:
c:\importlist.fmt -> 11.0 1 1 sqlchar 0 100 "\r\n" 1 text ""
query:
create table dbo.testbulk ( rowuid uniqueidentifier default newid() , value varchar(100) ) insert dbo.testbulk (value) select c.[text] openrowset( bulk n'c:\importlist.txt', formatfile = 'c:\importlist.fmt' ) c
Comments
Post a Comment