USE [HQEMPI] GO /****** Object: UserDefinedFunction [dbo].[SetSysID] Script Date: 03/22/2017 17:38:11 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION [dbo].[SetSysID] ( -- Add the parameters for the function here @pattype varchar(5) ) RETURNS varchar(10) AS BEGIN -- Declare the return variable here DECLARE @data_sys_id varchar(10) -- Add the T-SQL statements to compute the return value here SELECT @data_sys_id=case @pattype when 'O' then '0001' when 'I' then '0002' else @pattype end -- Return the result of the function RETURN @data_sys_id END GO
可编辑性=》函数=》标量值函数
调用时用dbo.标量名进行调用