开发者

Parsing backspace delimted text files using sqlserver 2005

开发者 https://www.devze.com 2022-12-15 17:48 出处:网络
I need to parse a back开发者_运维技巧space delimited flat file using sqlserver 2005 and update in some tables. What is the best way to go about it?Tried this?

I need to parse a back开发者_运维技巧space delimited flat file using sqlserver 2005 and update in some tables. What is the best way to go about it?


Tried this?

BULK INSERT MyTable
FROM 'c:\file.csv' 
WITH 
( 
    FIRSTROW = 2, 
    MAXERRORS = 0, 
    FIELDTERMINATOR = '\b', 
    ROWTERMINATOR = '\n' 
)

It may or not work with that delimeter, can also try \x08


Adam Machanic had a good article on writing SQLCLR string parsers. Check this out:

http://dataeducation.com/faster-more-scalable-sqlclr-string-splitting/


What you need is a C# Split like function in TSQL. Such a function doesn't exist. However, many people have written a function like this. For example:

http://blogs.vbcity.com/hotdog/archive/2008/06/04/9085.aspx

Randy

0

精彩评论

暂无评论...
验证码 换一张
取 消