We receive periodic tables in the TXT (CSV) format. We are to import them to an SQL Server table, but unfortunately the source TXT tables are not consistent over the periods (i.e. sometimes there’s a missing field, sometimes we get spaces before and after the content of a certain field, etc). One of the problems we have is that in a date field, ocassionally, there are blank spaces.
We need to import this field to a CHAR field which is 10 chars long. So whenever we get spaces before the date, we end up with an incomplete string. For example: “15/12/2005″ might get imported as ” 15/12/20″.
Is there a neat way to deal with this? I have read something about linked servers in SQL Server. I had thought about creating a linked server that points to the source TXT file, then run some TRIM query, but I’m not sure if this can be done. Anyway, I couldn’t pull it off at once. I think I need to create a schema.ini file in the same directory the source TXT is stored, but I don’t know how that’s done.
Any thought about this or other solution?