Re: Syntax problem with select from (if (exists (select....

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Kalen Delaney (replies_at_public_newsgroups.com)
Date: 07/13/04


Date: Tue, 13 Jul 2004 05:01:58 -0700

SQL Server's TSQL language does not support IIF.

--
HTH
----------------
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"Panks" <agarwalp@eeism.com> wrote in message
news:uGVlFmMaEHA.3112@TK2MSFTNGP09.phx.gbl...
> try using 'iif' instead of if. iif can be used in SQL statements. I have
> used it in MS Access but not in SQL.
>
> Syntax:  iif(Logical expression, true,false)
>
>
> "Jochen Daum" <jochen.daum@cabletalk.co.nz> wrote in message
> news:jb26f01pq4jns227k8igbo2gspeprhnqdq@4ax.com...
> > Hi,
> >
> > I want to integrate a subquery returning a boolean value into a query,
> > but I seem to have a synatx problem:
> >
> > Simplified it is
> >
> > select x from (if (exists (select 1)) 1 as x) as y (x)
> >
> > I am always confused by the lack of a 'then' so I think thats probably
> > where my mistake lies, but I can't seem to figgure it out. What ever I
> > do wity the if, there is always a syntax error near '(if' . I have put
> > the query in a range of lines in the QA to narrow down the error, but
> > it doesn't seem to be moving and I can't grasp, whats wrong with '(if'
> >
> > Any help?
> >
> > Jochen
> >
> >
> > --
> > Jochen Daum - Cabletalk Group Ltd.
> > PHP DB Edit Toolkit -- PHP scripts for building
> > database editing interfaces.
> > http://sourceforge.net/projects/phpdbedittk/
>
>


Relevant Pages

  • Re: Select only records past a key date
    ... Your written explanation doesn't match your example IIf() expression. ... The SQL translation of your written explanation is: ...
    (microsoft.public.access.queries)
  • Re: Compare Tables Structure
    ... Export the SQl of the table structures with the Enterprise Manager ... Jochen Daum - Cabletalk Group Ltd. ... PHP DB Edit Toolkit -- PHP scripts for building ...
    (microsoft.public.sqlserver.programming)
  • Re: Customized IIf procedure in SQL Server
    ... IIF function will be executed only for the result set and the impact on ... SQL Server. ... The two-part name is mandatory for a UDF and Boolean expressions ... On the other hand an example of when to use a UDF could be something like: ...
    (microsoft.public.sqlserver.programming)
  • Re: OPENROWSET problem
    ... IIF() is a VB/VBA equivalent to a simple CASE statement in T-SQL. ... MS Access uses its own bastardized blend of SQL and VBA, ...
    (microsoft.public.sqlserver.programming)
  • RE: blank for criteria in query field
    ... source (could be SQL Server, Oracle, Informix, Sybase,etc), what goes to the ... The IIf then provides the value to the Like ... Also the same criteria string was in an additional query ... that the report query was pulling from. ...
    (microsoft.public.access.queries)