SQL Server: How to Create a Function Using SQL Script

Опубликовано: 27 Март 2026
на канале: Saturday Night Coder
1,894
16

In this video we take a look at how to create a function in SQL Server using SQL script within SQL Server Management Studio.

Links:-

(Microsoft SQL Server Management Studio: How To Download & Use For Free)    • Microsoft SQL Server Management Studio: Ho...  
(SQL Server: How To Create A Table Using SQL Script)    • SQL Server: How To Create A Table Using SQ...  
(SQL Server: How to Insert Data into a Table Using SQL Script)    • SQL Server: How to Insert Data into a Tabl...  

Script:-

DROP FUNCTION IF EXISTS [dbo].[GetConfig]
GO

CREATE FUNCTION [dbo].[GetConfig](@Key VARCHAR(64)) RETURNS VARCHAR(512)
AS
BEGIN
RETURN(SELECT [c].[Value] FROM [dbo].[Config] [c] WHERE [c].[Key] = @Key)
END
GO

If you enjoyed the video don't forget to like, comment and subscribe. Thanks for watching.