hi,
thanq for question and ans.
yes, this is fine. we can use it.
but i have query like following
IIF(A.Calc_When = 'Ordered',B.Ordered_Flag =True and B.Ordered_Process = False,
IIF(A.Calc_When = 'Invoiced',B.Invoiced_Flag =True and B.Invoiced_Process = False,
IIF(A.Calc_When = 'Shipped',B.Shipped_Flag =True and B.Shipped_Process = False,
IIF(A.Calc_When = 'Paid',B.Paid_Flag =True and B.Paid_Process = False))) )
this is some nested iff.
here we r using field names in a join query.
so, i this solution not looking it can help me.
so, wand to have a user difined in-line function in sqlserver.
can any body pls help me in this regard?
i have done small work on it i have prepared one function like follow.
** (my intenstion is just replace iff with sqlIIF() SQLSERVER USERDEFINED FUNCTION)
it will not usefull but i want a function like this.
CREATE FUNCTION sqlIIF
(@ExpInString nvarchar(20),@flagYes varchar(10), @flagNo varchar(10))
RETURNS varchar(20)
AS
BEGIN
declare @Return varchar(20)
select @return = case @ExpInString
when 'True' then 'True'
when 'False' then 'False'
end
return @return
end
--- for try to execute
declare @flagval varchar(30)
print dbo.sqliif('True','true','false')
print @flagval
-----------------------------
thanQ
srikanth
sp_helptext sqliif
|