Usually, functions are created to incorporate re-usability features.
In the below query, we are trying to create a function which will return a string and this comes under "User defined function returning scalar values or scalar user defined function"
create function VenkatFunction()
returns varchar(100)
as
begin
return 'VenkatSample'
end
With encryption is an option to restrict other to view or modify the user defined functions.
create function VenkatFunction()
returns varchar(100)
with encryption
as
begin
return 'VenkatSample'
end
To access the function, you can use
select VenkatFunction()
Oops, it will thrown an error indicating "function is not a recognized built-in function name "
Solution: you need to use schema name in the front of the function to overcome this error.
You need to use select dbo.VenkatFunction()
Cheers,
Venkatesan Prabu .J
http://kaashivinfotech.com/
http://www.facebook.com/KaaShivInfoTech
No comments:
Post a Comment