When you say the name is “variable”, do you mean it can be a new value on each call, or do you mean it could be one of a set of predefined database names?
If the name is truly variable and unknown at compile time, then you will need to use dynamic SQL to build and execute your query.
If the name(s) are known at compile time, but you just want to be able to select from one of a set of databases, then you can use a series of IF or CASE statements at run time, e.g.:
<pre>procedure GetData (
if vFromDatabase = ‘DBOne’ then
select Data from DBOne.TableX where …
if vFromDatabase = ‘DBTwo’ then
select Data from DBTwo.TableX where …</pre>