How to convert oracle to_number to sql server?

Member

by kadin , in category: Third Party Scripts , 6 months ago

How to convert oracle to_number to sql server?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by orpha , 6 months ago

@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.

Related Threads:

How to convert partial dates in oracle sql?
How to import oracle sql file into mysql?
How to connect sql server with yii2?
How to connect to sql server with php?
How can I connect to sql server with php?
How to get 2 distinct rows from 1 row with 3 tables in sql oracle?