Solved

To convert Oracle Query to SQL SERVER Query

Posted on 2004-03-23
3
1,343 Views
Last Modified: 2012-05-04
Hi There ,
I've got this query which runs in Oracle , but the same query doesnt work in SQL Server

Select deal_no , deal_date
From (Select deal_no , deal_date From deals_hdr Where deal_no > 5000) ;

Is it possible to convert this query to ORACLE

Cheerio
Saju

0
Comment
Question by:sajuks
  • 2
3 Comments
 
LVL 33

Author Comment

by:sajuks
Comment Utility
Select deal_no , deal_date
From deals_hdr where  exists (Select deal_no , deal_date From deals_hdr Where deal_no > 5000) ;

will work.
 I want to know why oracle allows the above query while sql server does not.
0
 
LVL 1

Accepted Solution

by:
raje10410 earned 125 total points
Comment Utility
Hi Saju

Change your query as shown below. It'll surely work in SQL Server.

Select deal_no , deal_date
From (Select deal_no , deal_date From deals_hdr Where deal_no > 5000) AS DH ;

The trick is you refer the subquery by an alias. SQL Server has been designed to accept it only in this format.

Cheers,

Rajesh
0
 
LVL 33

Author Comment

by:sajuks
Comment Utility
Thanks Rajesh .
It works perfectly, any idea how to get the same thing working in Sybase?
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now