- 1). Click the Windows "Start" button and select "All Programs." Click "SQL Server," then click "SQL Server Management Studio" to open the database editor.
- 2). Click "New Query" in the Management Studio toolbar to open the editor for the SQL coding. Type the following command to create a SQL variable for the converted string:
declare @mystring varchar(30)
declare @converted decimal
The first variable holds the string, and the second variable contains the converted floating point decimal. - 3). Copy and paste the following code to convert the string to a floating point decimal:
set @mystring = '1.20'
set @converted = cast(@mystring as decmial)
The code uses the cast function to convert the number contained in the string variable to a decimal. The converted number is saved to the "@converted" variable. - 4). Press the "F5" key to execute the code. You can review the results in the results panel at the bottom of the window.
next post