Re: Dynamic SQL

From: Steve Thompson (SteveThompson_at_nomail.please)
Date: 05/23/03


Date: Fri, 23 May 2003 15:03:31 -0400


Take a look at the sp_executesql stored procedure, this should do what you
want.

Steve
"Shamim" <shamim.abdul@railamerica.com> wrote in message
news:#djSnbTIDHA.452@TK2MSFTNGP11.phx.gbl...
> 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 ?



Relevant Pages

  • Re: How do i move an SQLDatabase to another location?
    ... I went to my clients and installed SQL Server ... Express and copied my database to the same location it was in while i was ... knowing that i can bring a database with me and install ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: New to Windows CE Development - Have some questions
    ... validating against the main database, or querying the database during data ... iterate through the SQL CE table and create new entries in the ... SQL Server database that correspond. ... >>> not connected to the Enterprise. ...
    (microsoft.public.windowsce.app.development)
  • RE: Logging in in background
    ... wold take all kinds of modifictions as I'd need to be checking that each SQL ... my database and all have connection strings associated with them. ... I suspect that there is also an issue on the SQL Server side as I keep ...
    (microsoft.public.access.modulesdaovba)
  • RE: SBS 2003 Unable to connect to database STS_Config
    ... MSDE to store SharePoint uses the MSSQL$SharePoint database, ... SharePoint named instance to full SQL. ... You cannot upgrade the Monitoring instance to SQL ... What I see is the SQL server group and under ...
    (microsoft.public.windows.server.sbs)
  • Re: URGENT: SQL 6.5 Server Crash
    ... > Are these database backup done by SQL Server? ... > Or file backups performed by some Windows backup software? ... were they performed while SQL Server was running? ...
    (microsoft.public.sqlserver.server)