Link to home
Start Free TrialLog in
Avatar of NeGueSa
NeGueSaFlag for United States of America

asked on

Using IIf in SQLCommand

Im trying to pass this string to SQL from Visual Studio.net and I'm receiving the following ERROR : Incorrect syntax near '='
mySqlCommand.CommandText = "SELECT Table.acct_rep, Table..email, Table..cellular, Table..fax, IIF(Table..admin='Y','Owner','User') As newfield, Table..seq_id FROM [VS_DAT].[dbo].[Table] ORDER BY Table..acct_rep"

Can anyody help to write this in the right way?

Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

There is no IIF in SQL

SELECT Table.acct_rep, Table..email, Table..cellular, Table..fax, (CASE WHEN Table..admin='Y' THEN 'Owner' ELSE 'User' END) As newfield, Table..seq_id FROM [VS_DAT].[dbo].[Table] ORDER BY Table..acct_rep
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial