The following "Action query" works:
I can vary the database ... no problem.
But, if I need information returned like:
I have no way to communicate with the dynamic SQL. Any dynamic SQL
that supports a multiple DB really hates --> "Select @Var = Field..."
Rightfully so, because the @Var has a very short lifespan.
How can I do the above with a variable database?
Also, how could I declare a Cursor with a variable database (or table)?
Is it because the Dynamic SQL has no "user interface"?
Thanks,
Wayne
Code:
Declare @sql Varchar(200)
Declare @DB Varchar(50)
Set @DB = 'SomeDatabase'
Set @sql = 'Insert Into ' + @DB + '..SomeTable From SomeTable'
Execute @sql
I can vary the database ... no problem.
But, if I need information returned like:
Code:
Set @sql = 'Declare @HowMany Int ' +
'Select @HowMany = Count(*) From Sometable'
Execute @sql
I have no way to communicate with the dynamic SQL. Any dynamic SQL
that supports a multiple DB really hates --> "Select @Var = Field..."
Rightfully so, because the @Var has a very short lifespan.
How can I do the above with a variable database?
Also, how could I declare a Cursor with a variable database (or table)?
Is it because the Dynamic SQL has no "user interface"?
Thanks,
Wayne