[dba-SQLServer] Re: Iif in SQL Server

Robert L. Stewart rl_stewart at highstream.net
Wed Sep 22 14:01:41 CDT 2004


John,

No, CASE is valid in a SQL statement.  So, you
can use it in place of an IIF statement.

Robert

At 07:42 AM 9/22/2004 -0500, you wrote:
>Date: Wed, 22 Sep 2004 08:39:44 -0400
>From: "John W. Colby" <jwcolby at colbyconsulting.com>
>Subject: RE: [dba-SQLServer] Iif in SQL Server
>To: dba-sqlserver at databaseadvisors.com
>Message-ID: <002601c4a0a1$3fb6cd20$e8dafea9 at ColbyM6805>
>Content-Type: text/plain; charset=us-ascii
>
>Are we talking about code in an Sproc here?  I am not talking about
>AccessVB.  I am looking for something to work with 165 million records and
>return results in a few minutes.
>
>In the end I built a table with a PK field, a ZIPCode field and a Src field.
>I made the PK field a PK so that it has a unique index.  I then wrote two
>queries, one that pulls data from one field plus the PK plus a 1 as Src and
>appends it to my new table.  The other query pulls data from the other field
>plus the PK plus a 2 as the Src and appends to the table.  Run the first
>query.  All records that have anything in the ZIP code are put in the table.
>Run the second query.  All the records that have something in the second ZIP
>field but aren't already in the table get put in the table.
>
>Now I have a table with ONE field, with data from one or the other field,
>with a column which tells me which source field it came from, with a PK to
>join back up to the main table.
>
>Of course my second query is failing to append at all because the PK already
>exists in the new table.
>
>John W. Colby





More information about the dba-SQLServer mailing list