Hi all,
I'm hoping for some guidance on importing a flat file into a new SQL database table, specifically dealing with date columns.
On the source flat file I have several date fields; some of these fields have date values for every record, while some fields have values for records only when an event occurred for a particular record. Each record is, for example, a client. One of the columns in the data is a date on which the last statement was sent to the client and in some cases there have not been statements sent to a client and the value in this field is null. When populated, the value on the flat file is a string that reads "MM/DD/YYYY". I have tried three methods of importing the data.
First, when using the import wizard to create a new table from the flat file, I have specified that these date columns can contain null values, yet the process errors out. The error states it can not create the new table because data might be lost.
Second, I actually created a sql table with the same specifications as the flat file source, specifying that each date column can contain null values. Using the import wizard I mapped the flat file fields to the sql table columns I am trying to import the data to. Again, the process errors out.
Finally, frustrated with these two attempts, I simply created a a new sql table from the source data, but treating the date columns as string fields on the import. After importing the data, I changed the columns containing date values from string to date. This worked fine, except that on records that had a null date string on the flat file, when changing the data type to date in the sql table it automatically assigned dates of "1/1/1900 12:00:00 AM". Not exactly what I would have preferred, since I then have to run queries to null these particular values out.
I have a fairly good MS Access background, and this would never have given me trouble using that program to import data such as this. Howerver, being new to SQL, I'm obviously having some troubles here. Any suggestions would be appreciated.
|