Monday, June 8, 2009

Sql Hello World Function

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()

No comments:

Post a Comment