Hello,
Can anyone explain to me how I can create a function that I can use in SQL.
Thanks
It's pretty easy.
CREATE FUNCTION MyFunction(@variableOne datatype)
RETURNS datatype
AS
BEGIN
-- put function logic here
RETURN @variable
END
Then to call the function, you would use it in any SQL statement. For example
SELECT FIELD1, MyFunction(FIELD2) as ALIAS
FROM SOMETABLE;
Hope this helps
Andy
Thanks, that was very helpful
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.