-2

My simplified query is as follows.

select CustomerName as custname from customers where custname='Hey'

It says Column custname is not found. How can I handle this?

In sql it does not throw any exception and accepts custname as a column.

(In fact my query is more like select IIF(...,...,...) as name from customers where custname='Hey' than the above one.)

serdar
  • 1,564
  • 1
  • 20
  • 30

1 Answers1

0

Try change the column name. In many languages the "name" keyword is reserved

Edit

With the new query, try this:

select IIF(FPOLDOVTiP=0,99,FPOLDOVTiP) AS doviz from pol where IIF(FPOLDOVTiP=0,99,FPOLDOVTiP)=99

You can't use calculated fields on where clause.

ericpap
  • 2,917
  • 5
  • 33
  • 52
  • You are right. Looks like name is a reserved word http://msdn.microsoft.com/en-us/library/xztfc506%28v=vs.80%29.aspx – Bala Nov 21 '14 at 13:27
  • ok worked this time, thanks. Will this have a performance effect? Calculating twice? – serdar Nov 21 '14 at 13:45
  • Yes but the most performace effect will be to use a where on a calculated field. You can't index that search so it will have a perfomance impact for large tables. In that case You should consider change your table structure or the way you are saving data to avoid using calculated fields. – ericpap Nov 21 '14 at 13:49