NeGueSa
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','Owne r','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?
mySqlCommand.CommandText = "SELECT Table.acct_rep, Table..email, Table..cellular, Table..fax, IIF(Table..admin='Y','Owne
Can anyody help to write this in the right way?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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