SQL Server, boost your UDFs!
Hi Guys, Welcome back to my SQL Server tech blog Today we talk about UDF or User Defined Function. We'll see why UDFs are slow and mostly how to make them faster! Are you ready? What is an UDF? So, what is an User defined Function? An user defined function is a "procedure" written in T-SQL language. You can define a function through the syntax CREATE FUNCTION. For example: CREATE OR ALTER FUNCTION F_GET_PREZZO (@ARTID INTEGER) RETURNS FLOAT AS BEGIN DECLARE @Prezzo FLOAT SELECT @Prezzo = PREZZO FROM LISTINO WHERE ARTID=@ARTID; RETURN(@Prezzo) END; Once defined you can use your function inside your query: SELECT F_GET_PREZZO (ARTID) FROM LISTINO UDFs may have none, one o more input parameters and one output parameters. Let's say right away that in SQL Server we can have different types of UDF : Scalar functions that return one simgle value Multi-statement table valued functions also called TVF which...