Northwind Database (Document! X Sample)
dbo.ufnGetSalesOrderStatusText User Defined Function
AdventureWorks Database > dbo Schema : dbo.ufnGetSalesOrderStatusText User Defined Function
Description
Scalar function returning the text representation of the Status column in the SalesOrderHeader table.
Properties
Creation Date27/10/2017 14:33
Encrypted
Ansi Nulls
Parameters
ParameterDirectionDescriptionData TypeSize
InInput parameter for the scalar function ufnGetSalesOrderStatusText. Enter a valid integer.UnsignedTinyInt1
Return Value VarWChar15
Procedure Source Code
CREATE FUNCTION [dbo].[ufnGetSalesOrderStatusText](@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 'In process'
            WHEN 2 THEN 'Approved'
            WHEN 3 THEN 'Backordered'
            WHEN 4 THEN 'Rejected'
            WHEN 5 THEN 'Shipped'
            WHEN 6 THEN 'Cancelled'
            ELSE '** Invalid **'
        END;
    
    RETURN @ret
END;
See Also

Related Objects

dbo Schema
AdventureWorks Database