Collections:
CONVERT() - Converting Numeric Expression Data Types in SQL Server
How To Convert Numeric Expression Data Types using the CONVERT() Function in SQL Server Transact-SQL?
✍: FYIcenter.com
If you want to convert the data type of a numeric expression to a new data type, you can use the CONVERT(data_type, expression) function. The tutorial exercise below shows you how to use the CONVERT() function:
-- FLOAT converted to NUMERIC by CONVERT() DECLARE @pi FLOAT(24); SET @pi = 3.141592E+00; SELECT CONVERT(NUMERIC(5,2), @pi); GO 3.14 -- FLOAT converted to NUMERIC by CONVERT() DECLARE @x FLOAT(24); SET @x = 12345.12E+00; SELECT CONVERT(NUMERIC(10,5), @x); GO 12345.12012 -- FLOAT converted to INT by CONVERT() DECLARE @x FLOAT(24); SET @x = 12345.12E+00; SELECT CONVERT(INT, @x); GO 12345
Â
⇒Numeric Expressions and Functions in SQL Server Transact-SQL
2017-03-27, 2833👍, 0💬
Popular Posts:
What Are the Differences between DATE and TIMESTAMP in Oracle? The main differences between DATE and...
Where to find answers to frequently asked questions on Downloading and Installing SQL Server 2005 Ex...
What Happens to Your Transactions When ERROR 1213 Occurred in MySQL? If your transaction receives th...
How To Drop an Index in Oracle? If you don't need an existing index any more, you should delete it w...
How To Convert Binary Strings into Integers in SQL Server Transact-SQL? Binary strings and integers ...