dbTalk Databases Forums  

Decimal vs dot

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Decimal vs dot in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kari
 
Posts: n/a

Default Decimal vs dot - 07-26-2004 , 03:54 AM






Hi,
I have two types of ascii files.

File1
Col1;Col2;Col3
10,11;8,00;2,99

File2
Col1;Col2;Col3
10.11;8.00;2.99

; = col separator and , . are decimal marks.

I import files by DTS and File2 works fine but File 1 is
a problem.

I get general conversion failure source col DBTYPE_STR
and destination col DBTYPE_NUMERIC

What should I do?

Many thanks in advance!!!



Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Decimal vs dot - 07-26-2004 , 04:08 AM






The fact that you have , as the decimal notation is your problem here.

have a look at this

declare @s varchar(50)
declare @num decimal(3,2)
set @s = '123,34'
set @num = @s
select @num

Server: Msg 8114, Level 16, State 5, Line 4
Error converting data type varchar to numeric.

What i would be inclined to do is to import the file as is into a staging
area (varchar attributes) and do your manipulation from there so either do a
mass update on each attribute

UPDATE TABLE SET col1 = REPLACE(col1,',','.)..................

Or you can do it in your select when you go to put it back into SQL Server

SEELCT REPLACE(col1,',','.) as col1,............... FROM TABLE





--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Kari" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,
I have two types of ascii files.

File1
Col1;Col2;Col3
10,11;8,00;2,99

File2
Col1;Col2;Col3
10.11;8.00;2.99

; = col separator and , . are decimal marks.

I import files by DTS and File2 works fine but File 1 is
a problem.

I get general conversion failure source col DBTYPE_STR
and destination col DBTYPE_NUMERIC

What should I do?

Many thanks in advance!!!





Reply With Quote
  #3  
Old   
 
Posts: n/a

Default Re: Decimal vs dot - 07-27-2004 , 02:33 AM



Thanks this solved my problem!
rgds
Kari
Quote:
-----Original Message-----
The fact that you have , as the decimal notation is your
problem here.

have a look at this

declare @s varchar(50)
declare @num decimal(3,2)
set @s = '123,34'
set @num = @s
select @num

Server: Msg 8114, Level 16, State 5, Line 4
Error converting data type varchar to numeric.

What i would be inclined to do is to import the file as
is into a staging
area (varchar attributes) and do your manipulation from
there so either do a
mass update on each attribute

UPDATE TABLE SET col1 = REPLACE
(col1,',','.)..................

Or you can do it in your select when you go to put it
back into SQL Server

SEELCT REPLACE(col1,',','.) as col1,............... FROM
TABLE





--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Kari" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:3f2e01c472ee$2003cf40$a301280a (AT) phx (DOT) gbl...
Hi,
I have two types of ascii files.

File1
Col1;Col2;Col3
10,11;8,00;2,99

File2
Col1;Col2;Col3
10.11;8.00;2.99

; = col separator and , . are decimal marks.

I import files by DTS and File2 works fine but File 1
is
a problem.

I get general conversion failure source col DBTYPE_STR
and destination col DBTYPE_NUMERIC

What should I do?

Many thanks in advance!!!




.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.