Re: Dynamic SQL
From: ClairHolliday (clair_at_holliday1056.freeserve.co.uk)
Date: 05/25/03
- Next message: AJAY R: "Re: PREVENTING ACCESS"
- Previous message: Jasper Smith: "Re: Linked Servers - setspn - domain account"
- In reply to: Steve Thompson: "Re: Dynamic SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Sun, 25 May 2003 20:14:22 +0100
you could build the statement into a variable (@sql) and then execute the
variable (execute (@sql) this will give you 8000 characters to play with and
can apparently concatenate variables in the execute statement if 8000 isnt
enough
"Steve Thompson" <SteveThompson@nomail.please> wrote in message
news:#j8DC4VIDHA.336@tk2msftngp13.phx.gbl...
> 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: AJAY R: "Re: PREVENTING ACCESS"
- Previous message: Jasper Smith: "Re: Linked Servers - setspn - domain account"
- In reply to: Steve Thompson: "Re: Dynamic SQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|