Solved

To convert Oracle Query to SQL SERVER Query

Posted on 2004-03-23
3
1,353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Author Comment

by:sajuks
ID: 10656533
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
ID: 10656603
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
ID: 10673862
Thanks Rajesh .
It works perfectly, any idea how to get the same thing working in Sybase?
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

691 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