Tuesday, April 14, 2015

Create Function in sql

ALTER FUNCTION [dbo].[Test]
(
@user_id varchar(100)
)
RETURNS INT
AS
BEGIN
-- Declare the return variable here
DECLARE @vParaVal INT

-- Add the T-SQL statements to compute the return value here
SELECT @vParaVal = department_id from Test where [user_id] = @user_id

RETURN @vParaVal

END

No comments:

Post a Comment