The way I know of is to build a dynamic sql and then use the EXEC statement.... This is for ms-sql...<BR><BR>DECLARE @sqlString varchar(100)<BR>DECLARE @dbName varchar(100)<BR>SET @dbName = 'SomeDBName'<BR>SET @sqlString = 'SELECT * FROM ' + @dbName + '.SomeTable'<BR>EXEC(@sqlString)<BR><BR> It has problems though.. number one you cannot use outside variables in the string you'll have to concatinate it with the<BR>@sqlString. Also it is compiled on the fly. <BR><BR>Ive been learning the CASE statement.. but I do not know enough or if it is even possible to do dynamic db names with it... Anybody else have any other ideas?
Thanks foobar. <BR><BR>I just needed to know if its possible before i spend ages trying to make it work. Im a bit of a dab hand at case statements so if i get anywhere ill post a response here.<BR><BR>Kristian