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
 Transact-SQL (2000)
 Stored Procedure Parameters

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-05-14 : 10:43:43
sojesh writes "

How Can we pass a database object(eg.table)
as parameter to
a Stored Procedure?
"

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-05-14 : 10:48:31
Hi Sojesh.

You will have to pass it as a character string (varchar or something), and then use dynamic SQL in the procedure to reference the table.

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-05-14 : 10:57:57
I'm thiniking he wants to pass the whole object...not just the name...

This aint Oracle...



Brett

8-)
Go to Top of Page

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-05-14 : 10:59:58
Can you do that in Oracle??? Sounds mad... Imagine sending a million row table as a parameter... :)

Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-05-14 : 13:28:01
Yeah...and then you have people asking - "Why cant I pass a table datatype as a parameter into a sproc (just like Oracle)?!". Some people just dont get it, do they?

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-05-14 : 13:35:15
Whoah...you pass a pointer..not the data.

Oracle is very good at leaving things where they are and not constantly moving data round..

Seen lots of Oracle banging here because of cursors.

Applications can call procedures (in packages no less) that utilze reference cursors (which is a pointer to the data).

No data gets moved until its requested...it's a logical kind of thing.

SQL Server I think shoves all the data out when a sproc is called.

And still doesn't the calling application have to "spin" through the data anyway to utilize it (ie like a cursor?)


Until sojesh lets us know what s/he's doing, we'll never know.




Brett

8-)
Go to Top of Page

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-05-14 : 16:42:56
Well mate... The name of the object would be almost like a pointer wouldn't it? Too bad he'll have to use dynamic sql to manipulate the data in it :(

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-05-14 : 18:33:41
There's nothing to stop you from creating a temp table before you call the stored procedure. It will be within the scope of the sproc and it can process the temp table normally. Just need to make sure the temp table exists before you call it or you'll get an error.

Go to Top of Page
   

- Advertisement -