Use of USE databasename Within a Stored Procedure
Hi Rita,
First of all: why do you need to use the same procedure in different
databases? The only situation I can imagine if it's a procedure that
performs general DB-maintenance tasks. If you use this in a procedure
that performs business logic, than you might have a flawed design. If
you post more information, we can help you improve your design.
That being said, the answer to your question is that the only better way
than using dynamic SQL to do this is to not use it at all. Related data
should be in one database.
Are you aware of the risks of dynamic SQL? I heartily recommend you to
read Erland's site: http://www.sommarskog.se/dynamic_sql.html
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
|