Convert Oracle query to SQL query-digital conversion

Source: Internet
Author: User
Tags oracle rownum

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.