all groups > sql server programming > august 2007 >
You're in the

sql server programming

group:

Date in csv file are NULL!!!


Date in csv file are NULL!!! Marc Robitaille
8/27/2007 11:55:37 PM
sql server programming: Hello group

I need Assistance on this one. I have a VB6 application which imports csv
data in a database. There are 24 csv files. Some files contain dates like
this example

ENL80071666;REG00024;1999-01-01;1999-06-03;1999-12-31
ENL80071666;REG00024;2000-01-01;2000-01-01;2000-12-31
ENL80071666;REG00024;2001-01-01;2001-01-01;2001-12-31
ENL80071666;REG00024;2002-01-01;2002-01-01;2002-12-31
ENL80071666;REG00024;2003-01-01;2003-01-01;2003-03-31

They are imported in temporary tables with the help of this SP.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[I_TDE_Imports]
@FilePath VARCHAR(500),
@FileName VARCHAR(40),
@TableName VARCHAR(6)
AS

DECLARE @sql NVARCHAR(2000)
DECLARE @Delete NVARCHAR(40)

SET @Delete = 'TRUNCATE TABLE ' + @TableName

EXECUTE sp_executesql @Delete

SET @sql = 'INSERT INTO ' + @TableName + ' SELECT * FROM
OPENROWSET(''MSDASQL'', ''Driver={Microsoft Text Driver (*.txt;
*.csv)};DefaultDir=' + @FilePath + ';'',''SELECT * FROM ' + @FileName +
''')'

EXECUTE sp_executesql @sql

This is an exemple of my schema.ini

[TDE003.csv]
ColNameHeader=False
Format=Delimited(;)
MaxScanRows=0
CharacterSet=ANSI
COL1=no_empl char width 12
COL2=no_rrr char width 12
COL3=datda_rrr_perio date width 10
COL4=datad_empl_rrr date width 10
COL5=dat_ret_empl_rrr date width 10

Thereafter, there are several SP which are occupied of placing this
information in the working tables. On my laptop, all functions correctly. I
have two clients. One of them has many problems to import files which
contain dates. Sometime it works, sometime it don't. For a reason that I am
unaware of, all the date fields that are link to a date in the csv file are
Null in the temporary tables. However, his laptop has the same
configurations as mine. I don't understands.... Why this difference? and
most of all, where to look for a solution???????

I need help
Thank you very much
Marc R.

Re: Date in csv file are NULL!!! Uri Dimant
8/28/2007 12:00:00 AM
Are you talking to me?




[quoted text, click to view]

Re: Date in csv file are NULL!!! kishor
8/28/2007 3:30:03 AM
Hey ...
I have not gone through your mail .. but just giving you one hint .. may be
it works.

please check the datetime format of sql server and your machine. it could be
different.

Regards,
kishor



[quoted text, click to view]
Re: Date in csv file are NULL!!! Uri Dimant
8/28/2007 7:50:55 AM
Mark
I did some testing and it wokrd just fine. See on schema.ini file I have
changed for datetime columns
EXEC sp_addlinkedserver txtfile, 'Jet 4.0',
'Microsoft.Jet.OLEDB.4.0',
'c:\',
NULL,
'Text'
select *
into #temp
from txtfile...TDE003#csv


select * from #temp
go
drop table #temp

[TDE003.csv]
ColNameHeader=False
Format=Delimited(;)
DateTimeFormat=yyyy-mm-dd
MaxScanRows=0
CharacterSet=ANSI
COL1=no_empl Text
COL2=no_rrr Text
COL3=datda_rrr_perio DateTime
COL4=datad_empl_rrr DateTime
COL5=dat_ret_empl_rrr DateTime



















[quoted text, click to view]

AddThis Social Bookmark Button