Jimmy Underwood

Jimmy Underwood

  • NA
  • 118
  • 82.8k

Namesspace for Objects in Sql query

Feb 17 2012 5:25 AM
Hi,

I have a query, of very many lines, that I want to run in different MySQL and SQL Server databases. I want to avoid editing the From clause each time e.g. from [db1].[dbo].[Mytable] to [db2].[dbo].[Mytable] to db3.MyTable etc.

Is there a portable SQL way to define the context, sort of like a "namespace" in programming. As in, something like:

using context [db1].[dbo] //modify for each separate databases,environments
//rest of query