Wednesday, March 28, 2012

How to transform text in number?

How to transform text in numberHello Slim !
Try this:
Select Convert(INT, @.Textstring)
Jens Süßmeyer.|||Explaining better:
to convert ' 2.00 ' for 2,00
"Jens S meyer" <jsuessmeyer@.[REJECT_SPAM]web.de> wrote in message
news:ON2kpboZDHA.1280@.tk2msftngp13.phx.gbl...
> Hello Slim !
> Try this:
> Select Convert(INT, @.Textstring)
> Jens S meyer.
>|||Hello Slim !
Here some coding example: Try this:
DECLARE @.INTSTRING varchar(100)
SET @.INTSTRING = '2,001'
Select Replace(@.INTString,',','.')
Implicit convertion will be used, if you try to calculate with this value,
explicit convertion could be used by you:
Select
Convert(ANY_NUMERIC_DATATYPE_CHOOSEN_BY_YOU,Replace(@.INTString,',','.'))
Jens Süßmeyer.|||I am trying to matter and I am receiving that message
"Jens S meyer" <jsuessmeyer@.[REJECT_SPAM]web.de> wrote in message
news:e3hHKroZDHA.1744@.TK2MSFTNGP12.phx.gbl...
> Hello Slim !
> Here some coding example: Try this:
> DECLARE @.INTSTRING varchar(100)
> SET @.INTSTRING = '2,001'
> Select Replace(@.INTString,',','.')
> Implicit convertion will be used, if you try to calculate with this value,
> explicit convertion could be used by you:
> Select
> Convert(ANY_NUMERIC_DATATYPE_CHOOSEN_BY_YOU,Replace(@.INTString,',','.'))
> Jens S meyer.
>|||I am using SQL in Brazil, as I do to substitute (.) point for (,) comma
DECLARE @.INTSTRING char(100)
SET @.INTSTRING = '0.50'
--Select Replace(@.INTString,'.',',')
Select convert(decimal(9,2),@.INTSTRING)
"Jens S meyer" <jsuessmeyer@.[REJECT_SPAM]web.de> wrote in message
news:u5AJAIpZDHA.2136@.TK2MSFTNGP10.phx.gbl...
> OK, so then you need the other way, i am using a GERMAN SQL Server with ,
> separated numerics, so you have to replace the . with the , and vice versa
> in the replace function.
> Jens S meyer.
> "Slim" <fslim@.bol.com.br> schrieb im Newsbeitrag
> news:eOoHHEpZDHA.3768@.tk2msftngp13.phx.gbl...
> > Trying to convert received the message:
> >
> > DECLARE @.INTSTRING char(100)
> > SET @.INTSTRING = '2,001'
> > --Select Replace(@.INTString,'.',',')
> >
> > Select convert(decimal(10,5),@.INTSTRING)
> >
> > Server: Msg 8114, Level 16, State 5, Line 4
> > Error converting data type varchar to numeric.
> >
> >
> > "Jens S meyer" <jsuessmeyer@.[REJECT_SPAM]web.de> wrote in message
> > news:uPqtS$oZDHA.3436@.tk2msftngp13.phx.gbl...
> > > Try to transform it the way you will need it in the database (with
> > convert).
> > > If the target database needs decimal(10,5), convert it to
> > > convert(decimal(10,5),Column).
> > >
> > > Gru, Jens.
> > >
> > >
> > >
> >
> >
>sql

No comments:

Post a Comment