iif in MSSQL
dear all is there a way of doing the following in a query to MSSQL like you can to access? SELECT field1, field2, iif(field1 = field2,'same','different') AS mynote FROM mytable WHERE etc I appreciate it could be done in a SP or by analysing the output but in this case it is easier not to... thanks -- Regards; Richard Meredith-Hardy - r[dot]mh[at]flymicro[dot]com Tel: + 44 (0)1462 834776 FAX: + 44 (0)1462 732668 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: iif in MSSQL
> is there a way of doing the following in a query to MSSQL like you can > to access? > > SELECT field1, field2, iif(field1 = field2,'same','different') AS mynote > FROM mytable > WHERE etc > > I appreciate it could be done in a SP or by analysing the output but in > this case it is easier not to... > Check the docs for "CASE". The T-SQL equivalent should be something like: SELECT field1, field2, (CASE WHEN (field1 = field2) THEN 'same' ELSE 'different' END) AS mynote FROM mytable Maybe it's not worth creating a dedicated SP, but you could still but it inside a view and embed just a minum amount of SQL inside your CFML. You would end up with something like: SELECT * FROM my View WHERE etc Massimo Foti http://www.massimocorner.com [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: iif in MSSQL
Richard Meredith-Hardy wrote: > > is there a way of doing the following in a query to MSSQL like you can > to access? > > SELECT field1, field2, iif(field1 = field2,'same','different') AS mynote > FROM mytable > WHERE etc Look up the "CASE .. WHEN .. THEN blabla" statement. Maybe even Access understands this nowadays. Jochem [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: iif in MSSQL
http://www.extremeexperts.com/sql/faq/IIForDecode.aspx - Original Message - From: Richard Meredith-Hardy <[EMAIL PROTECTED]> Date: Mon, 20 Sep 2004 10:36:13 +0100 Subject: iif in MSSQL To: CF-Talk <[EMAIL PROTECTED]> dear all is there a way of doing the following in a query to MSSQL like you can to access? SELECT field1, field2, iif(field1 = field2,'same','different') AS mynote FROM mytable WHERE etc I appreciate it could be done in a SP or by analysing the output but in this case it is easier not to... thanks -- Regards; Richard Meredith-Hardy - r[dot]mh[at]flymicro[dot]com Tel: + 44 (0)1462 834776 FAX: + 44 (0)1462 732668 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: iif in MSSQL
Perfect. Thankyou! -- Regards; Richard Meredith-Hardy - r[dot]mh[at]flymicro[dot]com Tel: + 44 (0)1462 834776 FAX: + 44 (0)1462 732668 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]