Friday, February 17, 2012

Exporting text file and populate it as table using SQL

Hi,
I have a problem, I have some text files in the server. I have to export that file and read it line by line and then cut it into fields and populate it as a table in SQl with SQL commnads.

Could you anybody help mw with some hints, any relevent readings etc..
How can i use sql framework for thisIf you have control over how the text files can look like, I would recommend using the FOR XML and XML Shredding mechanisms (OpenXML, nodes() method).

Otherwise in SQL 2005, I would look into CLR user-defined functions to write the parsing code in your fav .Net language.

In SQL 2000, you would have to do it in TSQL or the mid-tier.

Also, if the data is not yet in the database but in a file, you can look into OpenRowset(BULK) in SQL Server 2005. Otherwise you need to read it in the mid-tier...

No comments:

Post a Comment