The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Dynamically choose sql catalog in stored proc

Is this possible? In my proc I want to select from a table in another catalog on the server, like "select * from catalog..tablename". The problem is that I won't know the other catalog name until runtime. I know I can do this by creating a string and using exec() but is there any other, less horrible way? CAn I somehow have the catalog name in a variable or something like that?

thanks in advance,
john
john
Thursday, February 02, 2006
 
 
Cant's you execute "USE [catelog name]" from the SP?
MBJ Send private email
Thursday, February 02, 2006
 
 
You don't say what world you live in, but in my world (MS SQL Server) the easiest (but not necessarily the best) is to dynamically build your SQL string, concatenating into the string the values for <server><database><table><whatever>, and then executing the string.

Of course, this goes against *everything* that stored procedures are all about, but it does work and is relatively simple to do.
Sgt.Sausage
Thursday, February 02, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz