Tuesday, July 5, 2011

SQL Server : You can use @table variables in udf, but not # or ## temp tables

The following code will throw error :

select * into ##tempaaa from LiveData

alter
returns
as
begindeclare @a bigintselect @a = max(id) from ##tempaaa
return @inp
end


The error will be :
Cannot access temporary tables from within a function.
int
function test(@inp int )

No comments:

Post a Comment