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
精彩评论