Re: Subqueries in SQL Server



SELECT ENAME
FROM EMP
WHERE DEPTNO = 10
AND SUBSTRING(ENAME,1,4) = 'SAHU';

Why wouldn't you write the query like this? For all intents and purposes, it
is the same as you nested query (in both ORacle and SQL Server), but easier
to read, IMHO.

--
Peter DeBetta, MVP - SQL Server
http://sqlblog.com
--
<sangu_rao@xxxxxxxxxxx> wrote in message
news:1168578207.262940.268520@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
Is there any similar statement in SQL Server for the below Oracle query

SELECT ENAME FROM (SELECT ENAME FROM EMP WHERE DEPTNO = 10)
WHERE SUBSTR(ENAME,1,4) = 'SAHU';

The above one is a Oracle query, i want to know is there any equivalent
query in SQL server.
I don't want to write the query as

SELECT ENAME FROM EMP WHERE DEPTNO = 10 AND SUBSTR(ENAME,1,4) = 'SAHU';

Please provide your comments.

Thanks
Rao



.



Relevant Pages

  • expression in unbound textbox
    ... and last name fields in the table, and aliased as EName. ... the query has ... added a textbox bound to EName, and the name shows up as expected in Report ... i've tried changing the textbox to a label control, ...
    (microsoft.public.access.reports)
  • Re: update two oracle tables with single SQL Query?
    ... single SQL Query?? ... You can update inline views ... update (select empno, ename, deptno, dname ...
    (comp.databases.oracle.misc)
  • Re: Subquery returned more than 1 value. This is not permitted when th
    ... First the query you posted is not a valid one. ... Set eName =(Select E.eName ... value it would apply to your "Set eName =" clause. ... subquery always returns only one value. ...
    (microsoft.public.sqlserver.server)
  • Re: update two oracle tables with single SQL Query?
    ... single SQL Query?? ... You can update inline views ... update (select empno, ename, deptno, dname ...
    (comp.databases.oracle.misc)
  • Re: CONTAINS performance
    ... That said, and with the query plan, I can start to give you more ... relational join in the context of the free-text optimization, ... SQL Server tables. ...
    (microsoft.public.sqlserver.fulltext)