Showing posts with label empid. Show all posts
Showing posts with label empid. Show all posts

Wednesday, March 28, 2012

query

hi,

i want to achive the IIF functionality.

example

select

iff(employee.empid is not null,'sdfsdf',iif(employee.deptid is not null,'dssdf','sdfsd')) as 'sdsd'

from employee

how to solve this.

thank you

Hi,

did not understand what you wants to achieve! You may use if and try...catch block or you may use case statements too.

Refer CASE and try...catch for more in BOL.

Regards

Heamntgiri S. Goswami

|||

IFF is not a part of TSQL syntax as far as i know...though this function is provided in sql server 2005 reporting services (thats the place i used it)...

finctionality of IFF is

IFF(mycondition , ValueWhenMyConditionTrue, ValueWhenMyConditionFalse)

IFF can also be nested...so for ValueWhenMyConditionFalse u can write another IFF...as is done in ur case...i hope u'll be able to 'decode' ur actual code now...

|||You can use an IF in SQL.

Its normally shown as

IF EXISTS (SELECT * FROM Orders WHERE OrderNo = @.OrderNo) THEN|||Also you use NotIsNull(Expr1, Expr2)
|||

IIF is not available in T-SQL.

But you can use Case When,

Case When employee.empid is NOT NULL Then 'sdfsdf' Else (Case When employee.deptid is not null Then 'dssdf' Else 'sdfsd' End) End

Tuesday, March 20, 2012

queries

1> how to select 3rd maximim salary from employee table
which contains empid,name,salary.
2> how to select duplicates from a table which doesnt have primary key
*** Sent via Developersdex http://www.codecomments.com ***
Please post this question in programming.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"murali yesuraj" <murali088@.hotmail.com> wrote in message
news:eUhkM1xnFHA.3304@.tk2msftngp13.phx.gbl...
> 1> how to select 3rd maximim salary from employee table
> which contains empid,name,salary.
> 2> how to select duplicates from a table which doesnt have primary key
>
> *** Sent via Developersdex http://www.codecomments.com ***