Home All Groups Group Topic Archive Search About

Passing a table into a function

Author
8 Sep 2006 7:32 PM
SQL Ken
I created a function and passing in a table however, it compains,

Can we pass in a table to a function??

anhting wrong with this? can't see the error

thanks

Ken

CREATE FUNCTION dbo.getLatestDate
  (
    @Original TABLE (Indx INT, ID INT, iDate DATETIME)
  )
RETURNS @Result TABLE (ID INT, iDate DATETIME)
AS
BEGIN

Author
8 Sep 2006 7:37 PM
Tracy McKibben
SQL Ken wrote:
Show quote
> I created a function and passing in a table however, it compains,
>
> Can we pass in a table to a function??
>
> anhting wrong with this? can't see the error
>
> thanks
>
> Ken
>
> CREATE FUNCTION dbo.getLatestDate
>   (
>     @Original TABLE (Indx INT, ID INT, iDate DATETIME)
>   )
> RETURNS @Result TABLE (ID INT, iDate DATETIME)
>  AS
> BEGIN
>

See "CREATE FUNCTION" in Books Online, it tells you exactly what data
types can be used as parameters...


--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Author
8 Sep 2006 7:45 PM
Aaron Bertrand [SQL Server MVP]
> Can we pass in a table to a function??

No.

A
Author
8 Sep 2006 8:02 PM
Mark Goldin
Send an xml string to a SP, then in SP dump xml into a temp table.

Show quote
"SQL Ken" <SQL***@gmail.com> wrote in message
news:1157743960.974305.179820@m79g2000cwm.googlegroups.com...
>I created a function and passing in a table however, it compains,
>
> Can we pass in a table to a function??
>
> anhting wrong with this? can't see the error
>
> thanks
>
> Ken
>
> CREATE FUNCTION dbo.getLatestDate
>  (
>    @Original TABLE (Indx INT, ID INT, iDate DATETIME)
>  )
> RETURNS @Result TABLE (ID INT, iDate DATETIME)
> AS
> BEGIN
>

AddThis Social Bookmark Button