Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting Float fields as part of an Insert
Message
De
18/11/2016 13:30:06
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Selecting Float fields as part of an Insert
Versions des environnements
SQL Server:
SQL Server 2014
OS:
Windows Server 2012
Divers
Thread ID:
01643678
Message ID:
01643678
Vues:
35
I am trying to create insert statements from a table of data from SQL Server to execute against an Oracle table of similar structure. I am struggling with a couple of float columns that seem to be converting to scientific notation. I do not want the values converted. SSMS query displays these values straight up so why can't I get them straight up?

This is my query to get my data out as Insert Statements but with no convert or cast causes an error.
SELECT 'INSERT INTO UCS_UNIT (Unit_ID, Description, QuantityFK, Factor, Multiplier, Last_Update) VALUES(''' +
	REPLACE(CAST(UnitID AS VARCHAR(36)),'-', '') + ''', ''' + Description + ''', ''' + REPLACE(CAST(QuantityFK AS VARCHAR(36)),'-', '') +
	''', ''' + Factor + ''', ''' + Multiplier +
	 ''', TO_DATE(''' + CONVERT(VARCHAR(19), LastUpdate, 121) +  ''', ''YYYY-MM-DD HH24:MI:SS''));' AS UCS_Unit
FROM uom.Unit WHERE Active = 1;
Trying to do some Cast and Convert comparisons gives me varying output but none are what I need.
select UnitID, Factor, CONVERT(VARCHAR(50), Factor, 128) As ConvertFactor,
CAST(Factor AS VARCHAR(50)) As CastFactor,
CAST(CAST(Factor AS Float) AS VARCHAR(50))AS CompountFactor
 from uom.Unit where QuantityFK = 'D9930486-53C3-41BD-9444-010E931EF061';
2551443.86974022	           2.55144386974022E6	      2.55144e+006	    2.55144e+006
86400	                          86400	                              86400	            86400
3153600000.3744	          3.1536000003744E9	      3.1536e+009	    3.1536e+009
157679960.138506	          1.57679960138506E8	      1.5768e+008	    1.5768e+008
2629822.96584	          2.62982296584E6	              2.62982e+006	    2.62982e+006
This is a one time data load that I won't be doing again. I wanted something down and dirty.
Only between 3,000 and 4000 rows.
Timothy Bryan
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform