Dynamic SQL

From: Shamim (shamim.abdul_at_railamerica.com)
Date: 05/23/03


Date: Fri, 23 May 2003 09:23:36 -0500


SQL SERVER 2K

Got a server with 15 databases, need to load data from 15 databases to a
common data-wearhouse database in the same server.

Developed a SP with INSERT ,UPDATE statements to load data.
I want to dynamically change database name in my SQL statements.

I created a table 'dbname' which stores all database name.
Inside my SP, using a CURSOR ,dynamically change the database name.

My issue is , I have lengthy INSERT / UPDATE statements, how to make it
work using 'EXEC' statement ??

For Example EXEC (' insert into xxxx
                                  select 50 columns from ' + @dbname +
'.dbo.yyyyy')

Any good approach to use EXEC for long SQL statements ??

Thanks
Shamim



Relevant Pages

  • RE: Backups have Shadow Copy Problems
    ... and restarted the server. ... suggested and changed the recovery model to simple on the one database called ... I understand the issue to be: the backup task failed ... You back up data from a volume that contains a Microsoft SQL Server ...
    (microsoft.public.windows.server.sbs)
  • Re: upsizing to sql 2005
    ... the word SERVER in it, ... You can access to the database by multiple means (Access, ... and how does it update the SQL database with the new records in Access? ... Query Name: Arcadia - ARC ...
    (microsoft.public.access.queries)
  • Re: Linked Tables in Access
    ... any use of SQL Passthru, Linked Tables or any other use of MDB / MDE ... server, or would I also need to convert *those* queries to passthrough ... I've been trying to understand why Access database files become corrupt. ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Leveling by ID vs. "Standard"
    ... of this trade called Project Management. ... a database for the "Project Tables," ... to write reports on data from the server database. ... product supporting queries created with SQL. ...
    (microsoft.public.project)
  • Re: Trouble Getting VS.Net 2003 WalkThroughs MSDE Connection
    ... Config Tool of SQL Server? ... > link to download the PUBs database. ... >>> Setup and they directed me to install MSDE and they attached a ...
    (microsoft.public.sqlserver.msde)