How to pass database name as parameter | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to pass database name as parameter

Hi all,
i have a small doubt.
we are building a inventory project using vb+sql server 2k
we create a new database for each finacial year to store our data
the problem here is i want to make one database to hold all the stored procedure
where in the stored procedure would take a parameter called dbname and will retrieve me data can i send database name as parameter.
eg Declare @db varchar(30)
set @db=’test’
EXEC(‘Select columns from ‘[email protected]+’..tableName’) Madhivanan Failing to plan is Planning to fail
adding to madhivanan trick,
you can even use three part naming like: database.owner.object
Why do you want to use a separate db for each single year? —
Frank Kalis
Microsoft SQL Server MVP
Heute schon gebloggt?
Ich unterst�tze PASS Deutschland e.V.