Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic table select using a variable

Status
Not open for further replies.

Margary

Computer
Jul 20, 2005
1
Hi

A question that got my mind wandering...



Let’s say I needed to change a .proc file. In the .proc file, I’m accessing a certain db. Let’s say if I didn’t know the name of the db during runtime (because the db name is dependent on a env variable) , I was thinking of creating a variable to store the name of the db (which is passed in through a perl wrapper script that calls the .proc).



Let’s say I have the following…



declare @my_db varchar(10)

select @my_db=”<whatever value is passed in through the perl script>”





Can I do the query below? If not, can you suggest a way on how I can do it ?





select * from @my_db..<name of the table>


Thanks,
Margary


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor