在存储过程中调用用户定义函数的方法是什么?

时间:2010-10-01 06:54:09

标签: sql-server tsql

使用select语句我们可以在存储过程中调用函数,是否有另一种方法可以在存储过程中调用函数。

2 个答案:

答案 0 :(得分:0)

尝试

SET @yourvariable = yourfunctionname('your params');

答案 1 :(得分:0)

getdate()你可以在proc中调用

-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE Proc1

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    declare @date datetime

   set @date= getdate()
END
GO