April 18, 2010 at 6:54 pm
Dear all,
I have a flatfile that has a Column that has text in 'ddmmyyyy' format. When I try to Import this into my Table that has a Column defiend as datetime it fails.
How can I resolve this. Thx.
April 18, 2010 at 9:06 pm
Buddy, how are u trying to import it? BCP , BULK insert, SSIS package, how?
April 18, 2010 at 9:12 pm
I am using DTS Import. Thx.
April 18, 2010 at 9:47 pm
Import it into your staging table as character based information and convert it when you transfer it to the final table.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 18, 2010 at 10:20 pm
I second Jeff.. any import from a flatfile should be put up in some holding table which will have nvarchar or varchar columns.. then apply your business logic and insert them into the staging table from where u can process the records...
April 19, 2010 at 3:33 am
Exactly how is it failing? It could be that the language settings for your SQL database aren't interpreting the ddmmyyyy format correctly.
April 19, 2010 at 4:41 pm
Thx for the Help guys.
I used the file - temp-table - real-table approach.
ddmmyyyy field was defined as a char(8) on the temp-table. All the fields from the flat file were simply 'copied' using DTS into the temp-table.
then, this sql cmd is run:
SET dateformat ymd
INSERT INTO [DSFM_Forecast]
SELECT DSFM_Forecast_tmp.Stock_Code, DSFM_Forecast_tmp.Customer_Group,
DSFM_Forecast_tmp.Whse_Code, 'SYS' AS FC_Type,
DSFM_Forecast_tmp.FC_Qty, stock_master.stk_std_cost * DSFM_Forecast_tmp.FC_Qty AS FC_Qty$_StdCost,
SUBSTRING(DSFM_Forecast_tmp.FC_Date, 5, 4) + '-' + SUBSTRING(DSFM_Forecast_tmp.FC_Date, 3, 2) + '-' + '1' AS YYYYMMDD,
SUBSTRING(DSFM_Forecast_tmp.FC_Date, 5, 4) + SUBSTRING(DSFM_Forecast_tmp.FC_Date, 3, 2) AS YYYYMM
FROM DSFM_Forecast_tmp LEFT OUTER JOIN
stock_master ON DSFM_Forecast_tmp.Stock_Code = stock_master.stock_code
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply