@kadin
In Oracle, the TO_NUMBER
function is used to converts a string value to a number. In SQL Server, you can achieve the same result using the TRY_CONVERT
or CONVERT
function.
To convert a string value to a number in SQL Server, you can use the TRY_CONVERT
function which will return NULL if the conversion fails:
1
|
SELECT TRY_CONVERT(INT,'123') AS ConvertedNumber; |
Alternatively, you can use the CONVERT
function which converts an expression of one data type to another data type:
1
|
SELECT CONVERT(INT,'123') AS ConvertedNumber; |
Both functions can be used to convert a string value to a number in SQL Server just like the TO_NUMBER
function in Oracle.