SQL中标准函数范例

 只做个人记录,不供大家学习。

USE [CRS_Brand]

GO

 

/****** Object:  UserDefinedFunction [dbo].[GetFactoryByID]    Script Date: 05/19/2013 21:59:44 ******/

SET ANSI_NULLS ON

GO

 

SET QUOTED_IDENTIFIER ON

GO

 

 

-- =============================================

-- Author:    peter qiu

-- Create date: 2013/05/15

-- Description:   <获取工厂名称>

-- =============================================

CREATE FUNCTION [dbo].[GetFactoryByID]

(

    @id uniqueidentifier

)

RETURNS varchar(50)

AS

BEGIN

    DECLARE @FactoryName varchar(100)

 

    SELECT @FactoryName=CompanyName from Factorys WHERE FactoryID=@id

 

    RETURN @FactoryName

END

GO

你可能感兴趣的:(sql)