How to write a sql function on any sql server?
Don't worry about. It is not hard as you think. Just try an example below. Try to understand the keywords.
create function hello_world()
Returns nvarchar(12)
AS
Begin
DECLARE @X nvarchar(12)
set @X='HELLO WORLD!'
return @X
end
You can run this function like:
print hello_world()
or
select hello_world()
Don't worry about. It is not hard as you think. Just try an example below. Try to understand the keywords.
create function hello_world()
Returns nvarchar(12)
AS
Begin
DECLARE @X nvarchar(12)
set @X='HELLO WORLD!'
return @X
end
You can run this function like:
print hello_world()
or
select hello_world()
Comments
Post a Comment