sql server - BULK INSERT tab-delimited file - unescape \x09 -
i'm using bulk insert load text file sql server created sql anywhere database. text file receiving has fields contain tab characters. in text file escaped "\x09".
can sql server recognize escape sequence?
there rows have enough of these escape sequences causing truncation error when bulk insert. i'd rather have sql server turn them in tab characters.
update (7/26): here's example file data
id name desc 1 value 1 text:\x09with tabs 2 value 2 more text:\x09with more\x09tabs
so, in example, takes 31 characters express value desc field record id 2. however, should inserted database 25 characters.
use temp table:
if object_id('tempdb..#test1') not null drop table #test1; go create table #test1 ( id integer not null, name varchar(30) not null, [desc] varchar(50) not null, ) bulk insert #test1 'd:\111.txt' ( fieldterminator = '\t', rowterminator = '\n' ); select id, name, replace([desc], '\x09', ''), '\x09' delimeter --into yourtable #test1
Comments
Post a Comment