--=========================================
-- SQL Server 2008 Unleashed Sample
-- Create scalar-valued function template
--=========================================
USE <database_name, sysname, bigpubs2008>
GO
IF OBJECT_ID (N'<schema_nm, sysname, dbo>.<func_nm, sysname, fn_myfunc>')
IS NOT NULL
DROP FUNCTION <schema_nm, sysname, dbo>.<func_nm, sysname, fn_myfunc>
GO
CREATE FUNCTION <schema_nm, sysname, dbo>.<func_nm, sysname, fn_myfunc>
(<parameter1, sysname, @param1> <parameter1_datatype,, int>,
<parameter2, sysname, @param2> <parameter2_datatype,, int>,
<parameter3, sysname, @param3> <parameter3_datatype,, int>)
RETURNS <return_value_datatype,,int>
WITH EXECUTE AS CALLER
AS
-- place the body of the function here
BEGIN
DECLARE <variable1, sysname, @var1> <variable1_datatype,, int>,
<variable2, sysname, @var2> <variable2_datatype,, int>
select <variable1, sysname, @var1> = isnull(<parameter1, sysname, @param1> )
<T-SQL_Body,,>
RETURN <variable1, sysname, @var1>
END
GO
|