lundi 13 avril 2015

how to use temporary table in function or use table type in sql server 2005

I have one stored procedure where I need to create temporary table/table type (I don't know exactly what to use). And I have one function which insert data according to matching case in the table (which is return type of function) of function. The scenario is like below.



stored_procedure
begin
@temp_table
my_function(@temp_table)
end


function my_function(@temp_table)
returns @result_table table
( value1 varchar(100),
value2 varchar(100),
... )
begin
case something -- > insert into @result_table
case something_1 -- > insert into @result_table
case something_2 -- > insert into @result_table
end


Note: I am working on SQL_SERVER 2005


The data of temporary table is needed in where clause (cross join in where condition) in various cases of function


Aucun commentaire:

Enregistrer un commentaire