problem with stored procedure
-
Hi, i want to write stored procedure insuch a way where in it has to return the table name used stored procedure. for example create procedure proc1 as begin select * from student end once u exit exec proc1 it has return the table name used i.e "Student" could you please help in doing this. or it is possible in sql. reply me soon at suhailquadri@gmail.com:-D Suhail Ahmed Mohammed, Application Engineer, Cybernet Slash Support
-
Hi, i want to write stored procedure insuch a way where in it has to return the table name used stored procedure. for example create procedure proc1 as begin select * from student end once u exit exec proc1 it has return the table name used i.e "Student" could you please help in doing this. or it is possible in sql. reply me soon at suhailquadri@gmail.com:-D Suhail Ahmed Mohammed, Application Engineer, Cybernet Slash Support
I don't think there is any way to do this. Besides, is it necessary? Stored procedure are usually coded to select data from a particular table or tables. You would know which table(s) each stored procedure used, so you could use an OUTPUT parameter to return a varchar value which was hard-coded to that table name for each stored procedure.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
-
Hi, i want to write stored procedure insuch a way where in it has to return the table name used stored procedure. for example create procedure proc1 as begin select * from student end once u exit exec proc1 it has return the table name used i.e "Student" could you please help in doing this. or it is possible in sql. reply me soon at suhailquadri@gmail.com:-D Suhail Ahmed Mohammed, Application Engineer, Cybernet Slash Support
This returns the query plus a table with 1 row - 1 column that contains the table name. Seems like a waste of time since the developer already knows the table name.
CREATE PROCEURE proc1 AS SELECT * FROM student SELECT 'student'
-
Hi, i want to write stored procedure insuch a way where in it has to return the table name used stored procedure. for example create procedure proc1 as begin select * from student end once u exit exec proc1 it has return the table name used i.e "Student" could you please help in doing this. or it is possible in sql. reply me soon at suhailquadri@gmail.com:-D Suhail Ahmed Mohammed, Application Engineer, Cybernet Slash Support
Thanks i got the solution.
-
I don't think there is any way to do this. Besides, is it necessary? Stored procedure are usually coded to select data from a particular table or tables. You would know which table(s) each stored procedure used, so you could use an OUTPUT parameter to return a varchar value which was hard-coded to that table name for each stored procedure.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
well using sp_depends storedprocedurename , it will list all the details of a stored procedure.
-
This returns the query plus a table with 1 row - 1 column that contains the table name. Seems like a waste of time since the developer already knows the table name.
CREATE PROCEURE proc1 AS SELECT * FROM student SELECT 'student'
Michael Potter wrote:
Seems like a waste of time since the developer already knows the table name.
It is.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
-
Michael Potter wrote:
Seems like a waste of time since the developer already knows the table name.
It is.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
you need to access the information about stored procedure dependencies written by another dba. I m displaying the information of stored procedure dependencies using sp_depends procedurename. It was requested by one of my client. Now programmetically i dispalyed in table and displayed accordingly.