Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert from varchar to int
Message
 
À
02/10/2007 11:21:30
Sergio Ortiz
Tek Services Group, Llc
Hollywood, Floride, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Services de reporting
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01257929
Message ID:
01257935
Vues:
13
This message has been marked as the solution to the initial question of the thread.
>Hello UT.
>
>
>DECLARE @idoc int
>DECLARE @doc varchar(8000)
>DECLARE @Amount varchar(20)
>
>SELECT @Amount = '$0.00';
>
>
>SELECT @doc=RatingWorksheetXML FROM PolicyRating WHERE PolID = '925379 '
>
>--Create an internal representation of the XML document.
>EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
>
>SELECT  @Amount = Amount FROM   OPENXML (@idoc, '/RateWorksheet/Item[Desc=''Windstorm Protective Devices Credit'']',2)
>			WITH (Amount varchar(30))
>
>
>SELECT @Amount  as Amount
>
>
>The value return of @Amount is "$17"
>I need to convert @Amount to int type to do some math substruction.
>
>
>Any help is appreciated.
>
>Thanks
DECLARE @idoc int
DECLARE @doc varchar(8000)
DECLARE @Amount varchar(20)

SELECT @Amount = '$0.00';


SELECT @doc=RatingWorksheetXML FROM PolicyRating WHERE PolID = '925379 '

--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc

SELECT  @Amount = Amount
       FROM   OPENXML (@idoc, '/RateWorksheet/Item[Desc=''Windstorm Protective Devices Credit'']',2)
       WITH (Amount varchar(30))

SELECT CAST(REPLACE(@Amount,'$','') as int)  as Amount
not tested

Are you sure the Amount should be int?
As I see it is a money, what will happens if you have value like 9.99?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform