Hi,
How can I access the value of a variable outside of
an exec statement.
I have tried the following
1:
declare @i int
set @i = exec ('select count(*) from table')
of course this does not work and I understand why
but I thought I would try anyway.
2:
exec ('declare @row int
set @row = (select count(*) from table)')
@row is not recognized outside of the exec stmt.
Declaring @row before the exec stmt does not work either
I want to be able to do this since I need to use an exec statement because the table name is actually a variable
(@tablename) and I want to use @row variable
elsewhere...
Thanks
ds
How can I access the value of a variable outside of
an exec statement.
I have tried the following
1:
declare @i int
set @i = exec ('select count(*) from table')
of course this does not work and I understand why
but I thought I would try anyway.
2:
exec ('declare @row int
set @row = (select count(*) from table)')
@row is not recognized outside of the exec stmt.
Declaring @row before the exec stmt does not work either
I want to be able to do this since I need to use an exec statement because the table name is actually a variable
(@tablename) and I want to use @row variable
elsewhere...
Thanks
ds