Last active
August 29, 2015 14:16
-
-
Save alikrc/c69a6d32a0b8acb8e079 to your computer and use it in GitHub Desktop.
some info about t-sql functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--table valued function | |
create function tableValuedFunction() | |
returns table | |
as | |
return(select * from TBL_FOO) | |
--using table-valued func | |
select * from tableValuedFunction() | |
--scalar valued func | |
create function scalarFunc(@ID int) | |
returns int | |
as | |
begin | |
return(@ID) | |
end | |
--using scalar func | |
select dbo.scalarFunc(2) | |
--using in select statement, in a view maybe? | |
select *, dbo.scalarFunc(TBL_FOO.id) from TBL_FOO | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment