Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import text file w/ numeric values as spaces

Status
Not open for further replies.

OasisChurch

Technical User
Mar 28, 2002
20
I have a text file exported from a Unisys system that I need to import into SQL Server. In several of the fields that are supposed to be numeric, the text file will actually contain a space for every value instead of a zero "0" or NULL
EX: field1 numeric(5) will contain 5 spaces in the text file. I changed all the numeric fields to varchar in my exsiting table and was hoping to modify that data after loading, however, there are serveral hundred fields and this takes 6 hours. Would it be faster to use an active X script to say "if field is numeric and source is not, add that entry as NULL?

Never written an active X script. is is hard o do?

thanks in advance!
--scott

 
well in the last conversion that i did i actualy used a comand line text replacment tool to do the job. I had to export the file from an old system, clean the file, then import it into our new system. As for your specif task I think that an active x script will do they arnt that hard to write.
 
Active X scripts are really easy. Just click on one of the transformations, delete it, select New, then chose Active X Script, then select Properties. Using the Browser and the Language window in the left bar it is really easy to quickly write a little function. Something like:
Code:
Function Main()
    If isNumeric(DTSSource("Field5"))
        DTSDestination("Field5") = null
    End if
    Main = DTSTransformStat_OK
End Function

The only thing I don't like is you don't get syntax highlighting.

As for speed, I'm not sure that this is the best way or if your data source should be a query, rather than a table, where you do your data manipulation there so it is a straight Copy Column transformation rather than in an Active X script. I usually deal with stuff under a million rows and I've not really noticed any appreciable difference using Active X Scripts, other may have different opinion though.

Journeyman -- The Order of the Seekers of Truth and Penitence
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top