Usman,
I don't think I've completely understood your problems - but
* if you need to generate an UPDATE statement for a number of tables,
I'd suggest you look into using sp_executesql rather than EXECUTE; this will
enable you to pass a parameter rather than having to rebuild the statement
in full in every pass
* EXEC ('SELECT' + ' '' UPDATE '' ' + '@ABC' ) -- Does Not Work;
enclosing @ABC in quotes will result in @ABC being returned; to return the
value stored in the variable, remove the quotes.
Charles
> -----Original Message-----
> From: Usman Farhat [SMTP:Usman.[Email Address Removed] Sent: Wednesday, October 23, 2002 3:12 PM
> To: LazyDBA.com Discussion
> Subject: Dynamic String !
>
> Hi Guys !
>
> If some one can help me in this situation , i could not manage it from
> last nigh ... i will be very thankful to you people ....
>
> This is a sample of my problem which actually relates to a bigger query
> stuff ... but actual problem stuff is this ...
>
> EXEC ('SELECT' + ' '' UPDATE TABLE '' ' )
> For Example This particular Code Line Returns Me Result :
>
> ---------------
> UPDATE TABLE
>
> ITS OK .. But i got a situation Where I wana Select Result Like This
>
>
> ----------------------
> UPDATE TABLE TableName
>
> WHILE TableName I wana Get Through Some Variable AS Dynamic Selection
>
> Some Stuff like this i need in Correct Format !
>
> Declare @ABC VARCHAR(10)
> set @ABC = 'Oye'
> EXEC ('SELECT' + ' '' UPDATE '' ' + '@ABC' ) -- Does Not Work
>
> I hope your people experience will help me out of this problem ...
> Thanks In Advance ...
>
> Usman Farhat
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: mssqldba-[Email Address Removed] For additional commands, e-mail: mssqldba-[Email Address Removed]MS Sql Server LazyDBA home page