Article View: comp.databases.ms-sqlserver
Article #79Re: How to convert from CHAR to Numeric in the table
From: Tibor Karaszi
Date: Thu, 29 Sep 2005 14:34
Date: Thu, 29 Sep 2005 14:34
26 lines
1923 bytes
1923 bytes
If you don't have any dirty data, you can do: UPDATE tblname SET invamt2 = CAST(invamt AS numeric(..., ...)) If you do have dirty data, you will get a datatype conversion error from above and need to clean your data first. -- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/ "Mac" <mac@hotmail.com> wrote in message news:TSS_e.10727$WT3.7999@trnddc03... > > I have imported some data to sql2k from my old system. Somehow, it imported invoice amount to > char type. > > I just created another column called invamt2 type NUMERIC so I can copy or convert content of > invamt which is type CHAR. There are about 50,000 records. > > How can I convert/cast from char type to numeric type ? > > Thanks >
Technical Details
Message-ID:
<uidmNMQxFHA.1168@TK2MSFTNGP10.phx.gbl>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!msrtrans!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gblReferences:
<TSS_e.10727$WT3.7999@trnddc03>Show Full Headers
Complete Article Headers
X-Google-Thread: 104de1,7a42fe3b69ba55f5 X-Google-Thread: ff490,7a42fe3b69ba55f5 X-Google-Thread: 10f695,7a42fe3b69ba55f5 X-Google-Attributes: gid104de1,gidff490,gid10f695,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Tibor Karaszi" <tibor_please.no.email_karaszi@hotmail.nomail.com> References: <TSS_e.10727$WT3.7999@trnddc03> Subject: Re: How to convert from CHAR to Numeric in the table Date: Thu, 29 Sep 2005 16:34:52 +0200 Lines: 27 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 Message-ID: <uidmNMQxFHA.1168@TK2MSFTNGP10.phx.gbl> Newsgroups: comp.databases.ms-sqlserver,cz.comp.microsoft.sql,microsoft.public.sqlserver.server NNTP-Posting-Host: h32n2fls31o1111.telia.com 213.64.47.32 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!newshub.sdsu.edu!msrtrans!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl