IF object_id(N'[dbo].[GetTaskAmount]', N'FN') IS NULL
BEGIN
DECLARE @Function varchar(MAX)
SET @Function =
'CREATE FUNCTION [dbo].[GetTaskAmount]
(
@Id int
)
RETURNS decimal
AS
BEGIN
DECLARE @Amount decimal
SELECT @Amount = Quantity * (SELECT Price FROM TaskTypes WHERE Id = TypeId) FROM Tasks WHERE Id = @Id
RETURN @Amount;
END'
EXEC(@Function)
END
BEGIN
DECLARE @Function varchar(MAX)
SET @Function =
'CREATE FUNCTION [dbo].[GetTaskAmount]
(
@Id int
)
RETURNS decimal
AS
BEGIN
DECLARE @Amount decimal
SELECT @Amount = Quantity * (SELECT Price FROM TaskTypes WHERE Id = TypeId) FROM Tasks WHERE Id = @Id
RETURN @Amount;
END'
EXEC(@Function)
END
Комментариев нет:
Отправить комментарий