Wednesday, March 7, 2012

copy content of txt file

Hi Guys,

What approach should I use to copy content of a text file. Is BCP capable of doing this? How about SSIS?

Example of the text file's content:

Date, "20060101"
ST_Code, "101"
A_Code, P_Code, T_Code, amount, price
"0001", "1111", "0101", 550, 230
"0002", "1111", "0102", 345, 122
"2001", 0212", 0930", 410, 90

In the example above, I just want to copy the rows Date, "20060101" and ST_Code, "101" into a table.

Regards,

Lars

Hi,

You could use DTS for this. Define a new DTS package, with your database in source, and a text file for output.

You can use an SQL order to filter your Data (..Where Date = "20060101" AND ....).

The result will be formatted as a CVS file by default. If you need to personalize your output format, you can use ActiveX scripts in transformation tasks to do this

ex :

Function Main()
DTSDestination("Date") = "Date, " & DTSSource("Date")
Main = DTSTransformStat_OK
End Function

|||

hi,

if you know the location of the row you want to copy you can use

the -f anf -l switch of BCP which stands for

-f = the first row

-l = the lastrow

regards,

joey

No comments:

Post a Comment