Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

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?

0
NeGueSa
Asked:
NeGueSa
  • 2
1 Solution
 
Brian CroweDatabase AdministratorCommented:
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
0
 
Brian CroweDatabase AdministratorCommented:
need to remove the double periods in your column references as well

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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now