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 2000 Forums
 SQL Server Development (2000)
 Creating temporary table from function

Author  Topic 

prakash
Starting Member

2 Posts

Posted - 2002-06-30 : 05:31:08
CREATE FUNCTION Evalue(@mShortName VARCHAR(100))
RETURNS VARCHAR
AS
BEGIN
DECLARE @mEmployeeID NUMERIC;
DECLARE @mEValue VARCHAR(4000);
DECLARE @mSQL VARCHAR(4000);
declare @parm1 as varchar(100)

SELECT
@mEmployeeID = N_EMPLOYEE_ID
FROM
PA_CURRENT_VALUES

-- SET @mSQL = 'SELECT @mEvalue = ' + @mShortName + 'FROM PA_VIEW_EMPLOYEE WHERE EMPID = ' + str(@mEmployeeID)

Create table #t(a int )

RETURN @mEvalue;
END


-----------

When I check the syntax it says, Cannot access temporaty tables from within function. What could be the reason













jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-06-30 : 11:01:58
The reason is that you are not allowed to.
Use a table variable - its not clear what you are trying to do with the temp table anyway ?

HTH
Jasper Smith
Go to Top of Page
   

- Advertisement -