Properties

Owner: dbo 
Type: SQL scalar function 
Encrypted:  
Creation Date: 04/26/2006 
Modification Date: 04/26/2006 
Description: Scalar function returning the text representation of the Status column in the SalesOrderHeader table. 

Creation options

QUOTED_IDENTIFIER:  
ANSI_NULLS:  

Parameters

Name Direction DataType Length Default Description
  @RETURN_VALUE  RETURN  nvarchar  15     
  @Status  INPUT  tinyint    Input parameter for the scalar function ufnGetSalesOrderStatusText. Enter a valid integer. 
Total: 2 parameter(s)

SQL

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

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;

GO
SET QUOTED_IDENTIFIER OFF
GO

GO
SET ANSI_NULLS OFF
GO

See Also

List of functions