IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = ?ufProductsInCategory?) DROP FUNCTION ufProductsInCategory GO CREATE FUNCTION ufProductsInCategory(@CategoryID AS int) RETURNS int AS Начало RETURN(SELECT COUNT(*) FROM Northwind.dbo.Products AS np WHERE np.CategoryID = @CategoryID) Конец GO