Re: Dynamic SQL
From: Steve Thompson (SteveThompson_at_nomail.please)
Date: 05/23/03
- Next message: Tom Moreau: "Re: User changing his/her own password"
- Previous message: Whitney: "User changing his/her own password"
- In reply to: Shamim: "Dynamic SQL"
- Next in thread: ClairHolliday: "Re: Dynamic SQL"
- Reply: ClairHolliday: "Re: Dynamic SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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 ?
- Next message: Tom Moreau: "Re: User changing his/her own password"
- Previous message: Whitney: "User changing his/her own password"
- In reply to: Shamim: "Dynamic SQL"
- Next in thread: ClairHolliday: "Re: Dynamic SQL"
- Reply: ClairHolliday: "Re: Dynamic SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|