AdventureWorks
dbo.ufnLeadingZeros User Defined Function
Description
Scalar function used by the Sales.Customer table to help set the account number.
Properties
Creation Date08/01/2010 08:40
Encrypted
Ansi Nulls
Parameters
ParameterDirectionDescriptionData TypeSize
@ValueInInput parameter for the scalar function ufnLeadingZeros. Enter a valid integer.int4
@RETURN_VALUEReturn Value varchar8
Objects that depend on dbo.ufnLeadingZeros
 Database ObjectObject TypeDescriptionDep Level
Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Individual and Store tables.1
Sales.CustomerAddress tableSales.CustomerAddressTableCross-reference table mapping customers to their address(es).2
iduSalesOrderDetail triggeriduSalesOrderDetailTriggerAFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column.4
Sales.Individual tableSales.IndividualTableDemographic data about customers that purchase Adventure Works products online.2
iStore triggeriStoreTriggerAFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.3
iuIndividual triggeriuIndividualTriggerAFTER INSERT, UPDATE trigger inserting Individual only if the Customer does not exist in the Store table and setting the ModifiedDate column in the Individual table to the current date.3
Sales.SalesOrderDetail tableSales.SalesOrderDetailTableIndividual products associated with a specific sales order. See SalesOrderHeader.3
Sales.SalesOrderHeader tableSales.SalesOrderHeaderTableGeneral sales order information.2
Sales.SalesOrderHeaderSalesReason tableSales.SalesOrderHeaderSalesReasonTableCross-reference table mapping sales orders to sales reason codes.3
Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.2
Sales.StoreContact tableSales.StoreContactTableCross-reference table mapping stores and their employees.3
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.vIndividualDemographics viewSales.vIndividualDemographicsViewDisplays the content from each element in the xml column Demographics for each customer in the Sales.Individual table.3
Sales.vSalesPersonSalesByFiscalYears viewSales.vSalesPersonSalesByFiscalYearsViewUses PIVOT to return aggregated sales information for each sales representative.3
Sales.vStoreWithDemographics viewSales.vStoreWithDemographicsViewStores (names and addresses) that sell Adventure Works Cycles products to consumers.2
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

 

 


© 2012 All Rights Reserved.

Send comments on this topic.