Login     Register

        Contact Us     Search

XLeratorDB/strings Online Documentation

SQL Server IIFSTR function


IIFSTR

Updated: 30 April 2009

Use IIFSTR to return one of two parts, depending on the evaluation of an expression.
 Syntax
SELECT [wctString].[wct].[IIFSTR] (
   <@Condition, bit,>
 ,<@TrueValue, nvarchar(max),>
 ,<@FalseValue, nvarchar(max),>)
Arguments
@Condition
the expression being evaluated. The @Condition argument can be an expression of types that are implicitly convertible to bit.
 
@TrueValue
the value returned if @Condition is true. The @Truevalue argument can be of data types that are implicitly convertible to nvarchar or ntext.
 
@FalseValue
the value returned if @Condition is false. The @Falsevalue argument can be of data types that are implicitly convertible to nvarchar or ntext.
 
Return Types
nvarchar(max)
Examples

CREATE
TABLE #i (
      [recno] [float] NOT NULL,
      [numerator] [float] NOT NULL,
      [denominator] [float] NOT NULL
)
INSERT INTO #i VALUES( 1, 3, -1)
INSERT INTO #i VALUES( 1, 3, 0)
INSERT INTO #i VALUES( 1, 3, 1)
SELECT recno
,numerator
,denominator
,Numerator / wct.IIFSTR(denominator, denominator, .01)
from #i
This produces the following result
recno                  numerator              denominator           
---------------------- ---------------------- ---------------------- ----------------------
1                      3                      -1                     -3
1                      3                      0                      300
1                      3                      1                      3
 
(3 row(s) affected)


Copyright 2008-2013 WestClinTech LLC         Privacy Policy        Terms of Service