Northwind Database (Document! X Sample)
dbo.ufnLeadingZeros User Defined Function
AdventureWorks Database > dbo Schema : dbo.ufnLeadingZeros User Defined Function
Description
Scalar function used by the Sales.Customer table to help set the account number.
Properties
Creation Date27/10/2017 14:33
Encrypted
Ansi Nulls
Parameters
ParameterDirectionDescriptionData TypeSize
InInput parameter for the scalar function ufnLeadingZeros. Enter a valid integer.Integer4
Return Value VarChar8
Objects that depend on dbo.ufnLeadingZeros
 Database ObjectObject TypeDescriptionDep Level
Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Person and Store tables.1
iduSalesOrderDetail triggeriduSalesOrderDetailTriggerAFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column.3
Sales.SalesOrderDetail tableSales.SalesOrderDetailTableIndividual products associated with a specific sales order. See SalesOrderHeader.2
Sales.SalesOrderHeader tableSales.SalesOrderHeaderTableGeneral sales order information.2
Sales.SalesOrderHeaderSalesReason tableSales.SalesOrderHeaderSalesReasonTableCross-reference table mapping sales orders to sales reason codes.3
dbo.ufnGetContactInformation functiondbo.ufnGetContactInformationUser Defined FunctionTable value function returning the first name, last name, job title and contact type for a given contact.2
uSalesOrderHeader triggeruSalesOrderHeaderTriggerAFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables.3
Sales.vIndividualCustomer viewSales.vIndividualCustomerViewIndividual customers (names and addresses) that purchase Adventure Works Cycles products online.2
Sales.vSalesPersonSalesByFiscalYears viewSales.vSalesPersonSalesByFiscalYearsViewUses PIVOT to return aggregated sales information for each sales representative.3
Procedure Source Code
CREATE FUNCTION [dbo].[ufnLeadingZeros](
    @Value int
) 
RETURNS varchar(8) 
WITH SCHEMABINDING 
AS 

BEGIN
    DECLARE @ReturnValue varchar(8);

    SET @ReturnValue = CONVERT(varchar(8), @Value);
    SET @ReturnValue = REPLICATE('0', 8 - DATALENGTH(@ReturnValue)) + @ReturnValue;

    RETURN (@ReturnValue);
END;
See Also

Related Objects

dbo Schema
AdventureWorks Database