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)
 Dynamically Modifying Stored Procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-03-11 : 07:10:36
Srinivasan writes "Hi All,
We are building a web Application, where we have some dynamic form fields. That is we are creating,updating,deleting columns of a table on fly according to user input.
Now we have some stored procedures having select,insert, update,delete queries on the above dynamic table. Since the table columns are going to be dynamically changing, we have to modify sql statements in these stored procedures also dynamically whenever a column is added,updated or deleted to the table.

Can Someone suggest us a good efficient way of doing this. Also please advice on whether this kind of dynamic modification of stored procedures are advisable.

Thanks in Advance
Srinivasan "

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-03-11 : 07:14:32
Hi!

I would not advice such a solution. It would be a better idea to design the database for this kind of system to begin with.

If you still want to try it, I suggest using the information_schema views to build dynamic SQL statements instead of altering the procedure code.

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-03-11 : 07:14:55
quote:
We are building a web Application, where we have some dynamic form fields. That is we are creating,updating,deleting columns of a table on fly according to user input.
Bad idea. Stop doing this right now. There's no point in using a database system to store your data if you haven't determined what you're going to store. Excel is better suited for this.
quote:
Now we have some stored procedures having select,insert, update,delete queries on the above dynamic table.
GOOD! That's the type of thing you should be doing. However...
quote:
Since the table columns are going to be dynamically changing, we have to modify sql statements in these stored procedures also dynamically whenever a column is added,updated or deleted to the table.
...doing this ruins the whole purpose of using stored procedures.
quote:
Can Someone suggest us a good efficient way of doing this.
Yeah, don't do it. There is no good or efficient way.
quote:
Also please advice on whether this kind of dynamic modification of stored procedures are advisable.
It's not. Don't do it.

Go to Top of Page
   

- Advertisement -