![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is it possible to pass a table as a parameter to a funtion. |
|
my problem is: i have to access a temporary table created in an SP in a function ALTER PROCEDURE MySP BEGIN .... DECLARE @TmpTable TABLE(...) .... TempFunction(@TmpTable) .... END |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
|
As already suggested a procedure will work. We have a procedure to drop all default constraints from our tables. I pass in a list of tables to this procedure (the list of tables are loaded in to a table variable by calling a function). If you need further help then re-post and I can hopefully give you an example! Paul |

#6
| |||
| |||
|
|
Ya.. the procedure will do fine.... But my question is that is there any performance difference between using functions and procedure.... |
#7
| |||
| |||
|
|
Is it possible to pass a table as a parameter to a function. |
|
I have to access a temporary table created in an SP in a function |
#8
| |||
| |||
|
|
Is it possible to pass a table as a parameter to a function. Please read a book, any book, on data modeling, and RDBMS. A table is an entity or a relationship. That would mean you have a magical, super function that works on Squids, Automobiles, Britney Spears, Geographical locations or anything in the whole of creation. |
|
Or you have a bad design which you are not showing us. That is what Ia m beting. |
|
I have to access a temporary table created in an SP in a function No, you do not. You just don't know how to write declarative, non- procedural code so you are mimicking a scratch tape with a table that appears out nowhere in your data model as if you were still using a magnetic tape file system instead of an RDBMS. |
#9
| |||
| |||
|
|
No; it would much more likely mean that he wants to pass a set of values to his function. |
|
the ability to simply pass a set would make things enormously easier, faster, and cleaner - which is probably why they're including it in SQL 2008. |
|
I can think of several scenarios in which doing exactly what he is asking would be necessary - reporting being the most obvious. |
#10
| |||
| |||
|
|
No; it would much more likely mean that he wants to pass a set of values to his function. Not very likely at all. Read the last 5+ years of postings here and you will see that when they want to pass a list to an IN() predicate, they explicitly ask about that. When they want to pass a table they explicitly ask about that, as this guy did. |
|
the ability to simply pass a set would make things enormously easier, faster, and cleaner - which is probably why they're including it in SQL 2008. Right now you can declare a huge number of parameters in a stored procedure -- more than enough for any practical situation. But programmers who grew up with BASIC and other interpreted languages seem to panic at the the thought of a long parameter list. |
![]() |
| Thread Tools | |
| Display Modes | |
| |