Northwind Database (Document! X Sample)
dbo.ufnGetPurchaseOrderStatusText User Defined Function
AdventureWorks Database > dbo Schema : dbo.ufnGetPurchaseOrderStatusText User Defined Function
Description
Scalar function returning the text representation of the Status column in the PurchaseOrderHeader table.
Properties
Creation Date27/10/2017 14:33
Encrypted
Ansi Nulls
Parameters
ParameterDirectionDescriptionData TypeSize
InInput parameter for the scalar function ufnGetPurchaseOrdertStatusText. Enter a valid integer.UnsignedTinyInt1
Return Value VarWChar15
Procedure Source Code
CREATE FUNCTION [dbo].[ufnGetPurchaseOrderStatusText](@Status [tinyint])
RETURNS [nvarchar](15) 
AS 

-- Returns the sales order status text representation for the status value.
BEGIN
    DECLARE @ret [nvarchar](15);

    SET @ret = 
        CASE @Status
            WHEN 1 THEN 'Pending'
            WHEN 2 THEN 'Approved'
            WHEN 3 THEN 'Rejected'
            WHEN 4 THEN 'Complete'
            ELSE '** Invalid **'
        END;
    
    RETURN @ret
END;
See Also

Related Objects

dbo Schema
AdventureWorks Database