Solved

To convert Oracle Query to SQL SERVER Query

Posted on 2004-03-23
3
1,352 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where clause to fliter varchar with Characters 12 52
SQL Lag Function DateDiff 2 25
Powershell error using sql agent job 24 32
mssql 7 32
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

738 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