Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 table function and temp funcion

Author  Topic 

Sqlmm
Starting Member

3 Posts

Posted - 2011-10-12 : 09:03:45
Hello

i have a function, and i want to create a temp table inside my function, but im not returning anything in my function. so i have something like

CREATE FUNCTION dbo.function
(
String varchar(1000)
)
Returns table
AS
RETURN
(

så her i want to put my temp table or is it not possible ?
)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-12 : 12:07:01
you cant create temp table. you can create table variable though. it should be like:-

CREATE FUNCTION dbo.function
(
String varchar(1000)
)
Returns @tablename table
(
columns....
)

AS
BEGIN
....

END

or

CREATE FUNCTION dbo.function
(
String varchar(1000)
)
Returns table
AS
RETURN
(

your select query with full resultset
)



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -