--4. Creating procedures
CREATE PROCEDURE say_hello AS
BEGIN
	print 'Hello World'
END
--and running them
exec say_hello

--5. Creating functions
CREATE FUNCTION Capitalise(@str varchar(2000)) RETURNS varchar(2000) AS
BEGIN
	return upper(substring(@str,1,1))+lower(substring(@str,2,len(@str)-1))
END
--and using them in sql
SELECT product, dbo.capitalise(product) as result
FROM products

--Any many other constructs such as triggers and transactions
