function key icon Function: ufnGetProductStandardCost

Properties

Property Value
Name ufnGetProductStandardCost
ID 39671189
Schema dbo
Owner dbo
Execute As Caller
Type SQL SCALAR FUNCTION
Uses Ansi Nulls true
Uses Quoted Identifier true
Is Schema Bound false
Uses Database Collation false
Null on Null Input false
Encrypted false
MS Shipped false
Published false
Schema Published false
Deterministic false
Precise false
System Verified false
System Data Access true
User Data Access true
Modify Date 8/8/2010 5:23:46 PM
Creation Date 8/8/2010 5:23:46 PM

Extended Properties

Name Value
MS_Description Scalar function returning the standard cost for a given product on a particular order date.

Permissions

No object level permissions defined.

Parameters

Parameter Name Datatype Has Default Value Default Value Read Only Xml Document Description
@ProductID int false false false Input parameter for the scalar function ufnGetProductStandardCost. Enter a valid ProductID from the Production.Product table.
@OrderDate datetime false false false Input parameter for the scalar function ufnGetProductStandardCost. Enter a valid order date.

Recordset Returned

Datatype Has Default Value Default Value Xml Document Description
money false false

Objects that depend on [ufnGetProductStandardCost]

Objects on which [ufnGetProductStandardCost] depends

SQL

Script
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE FUNCTION [dbo].[ufnGetProductStandardCost](@ProductID [int], @OrderDate [datetime]) RETURNS [money] AS BEGIN DECLARE @StandardCost money; SELECT @StandardCost = pch.[StandardCost] FROM [Production].[Product] p INNER JOIN [Production].[ProductCostHistory] pch ON p.[ProductID] = pch.[ProductID] AND p.[ProductID] = @ProductID AND @OrderDate BETWEEN pch.[StartDate] AND COALESCE(pch.[EndDate], CONVERT(datetime, '99991231', 112)); -- Make sure we get all the prices! RETURN @StandardCost; END;
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Input parameter for the scalar function ufnGetProductStandardCost. Enter a valid ProductID from the Production.Product table.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'ufnGetProductStandardCost', @level2type=N'PARAMETER',@level2name=N'@ProductID'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Input parameter for the scalar function ufnGetProductStandardCost. Enter a valid order date.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'ufnGetProductStandardCost', @level2type=N'PARAMETER',@level2name=N'@OrderDate'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Scalar function returning the standard cost for a given product on a particular order date.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'FUNCTION',@level1name=N'ufnGetProductStandardCost'

See also

List of Functions