Skip to content

Instantly share code, notes, and snippets.

@alikrc
Last active August 29, 2015 14:16
Show Gist options
  • Save alikrc/c69a6d32a0b8acb8e079 to your computer and use it in GitHub Desktop.
Save alikrc/c69a6d32a0b8acb8e079 to your computer and use it in GitHub Desktop.
some info about t-sql functions
--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