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
 SQL Server Development (2000)
 STORED PROCEDURES

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-08 : 09:37:40
RAVI writes "I WOULD LIKE TO FIND A WAY BY WHICH I CAN CREATE STORED PROCEDURE PARAMETERS ON THE FLY BASED ON THE NO OF COLUMNS OF A PARTICULAR TABLE. THIS WILL HELP ME IN CREATING DYNAMIC INSERT,UPDATE AND DELETE STORED PROCEDURES.
THIS PROCEDURE WHICH I HAVE IN MIND WILL CHANGE ITS PARAMETERS DYNAMICALLY BASED ON THE COLUMNS OF THE TABLE SELECTED BY THE USER.
IS IT POSSIBLE TO DO SO?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-05-08 : 10:36:31
No. 1: DO NOT USE ALL CAPITAL LETTERS! IT IS EXTREMELY ANNOYING!

No. 2: You won't be doing yourself any favors by trying to create a generic and dynamic stored procedure to insert into a table. If it can even be done, which I highly doubt, you'll gain none of the benefits that stored procedures provide. You're essentially building a dynamic INSERT/DELETE/UPDATE statement that you then want to execute; wrapping it into a stored procedure would only slow it down, since it would also have to create the dynamic procedure.

I really don't understand why you'd want to do this in the first place. It would be MUCH LESS work if you created the appropriate procedures for each table individually. You don't believe me only because you haven't tried it yet. I imagine that you've tried to do a generic procedure like you described, and haven't been successful. I think you should forget about it and focus on doing it the right way.

Go to Top of Page
   

- Advertisement -