Sounds like you need to use dynamic sql. See here for more details:
http://www.sommarskog.se/dynamic_sql.html
--
Andrew J. Kelly SQL MVP
"whornak" <whornak (AT) discussions (DOT) microsoft.com> wrote
Quote:
I have a table that I need to reference that is not always in the same
database as all other tables. I have available to me the database name
the
table exists in but can't get my sql statement to accept an input
parameter
containing the database that I need to join to.
Does anyone know how to structure a sql statement so one of the joined
tables is within a variable database? |