How can I convert Oracle queries to queries in the SQL database? The following describes how to convert an Oracle query to an SQL query. If you are interested in Oracle query, take a look.
Oracle's TO_CHAR function can convert the n-bit NUMBER data type to the VARCHAR2 data type and use an optional numeric format.
SQL Server Returns the character data after numeric conversion through the STR function. However, this function does not have a convenient Format parameter.
Oracle query:
SELECT to_char123.45, 99999999999999) from tab
SELECT to_charEXPIRY_DATE, 'ddmonyyyy') from tab
The following are SQL Server version queries:
SELECT STR123.45, 14)
SELECT STRround123.455, 2), 12, 2)
SELECT CASTREPLACECONVERTvarchar12 ),
EXPIRYDATE, 106), '','') as varchar9 ))
LENGTH and LEN
Oracle queries are as follows:
Select length 'sqlmag ')
"Length in characters" from dual;
The preceding query is written in the following way in SQL Server:
Select len 'sqlmag') "Length in characters"
Date
The date obtained by Oracle is as follows:
SYSDATE
SQL Server is like this:
GETDATE)
You can use various syntaxes to operate dates.
The following code specifies the Oracle date
The month in the value is formatted and the returned date plus n months ):
Select add_monthssysdate, 12) from dual
SQL Server performs the same functions as follows:
Select dateaddmm, 12, getdate ))
Data Subtraction is also different. The following code is directly used in Oracle:
Perform the following operations to subtract data:
SELECT sysdate-add_monthssysdate, 12) FROM dual
SQL Server does this:
SELECT datediffdd, GetDate), dateaddmm, 12, getdate )))
Use of oracle rownum statements
Introduction to Oracle index rules
Step 5: Create an oracle full-text index
How to create an Oracle Index
C # connect to the Oracle database to query data