Dears,
I have a table with SQL Commands in it, and I want to create a result set
with the values powered by these commands.
I'm intending to create a stored procedure with a temporary table with that
values and use it as a result set.
Is it possible to make it using EXECUTE (@.SQLCOMMAND) ?
Does any body have another idea ?
Thanks in advantage,
Rodrigo.Rodrigo
DECLARE @.name as nvarchar(50),@.sql as nvarchar(200)
SET @.sql=N'select @.name = col_name FROM Table WHERE col=99'
EXEC sp_executesql @.sql, N'@.name nvarchar(50) OUTPUT',
@.name= @.name OUTPUT
SELECT @.name
"Rodrigo" <rborges11@.hotmail.com> wrote in message
news:OlLOwtE1DHA.1336@.TK2MSFTNGP12.phx.gbl...
> Dears,
> I have a table with SQL Commands in it, and I want to create a result set
> with the values powered by these commands.
> I'm intending to create a stored procedure with a temporary table with
that
> values and use it as a result set.
> Is it possible to make it using EXECUTE (@.SQLCOMMAND) ?
> Does any body have another idea ?
> Thanks in advantage,
>
> Rodrigo.
>|||"Rodrigo" <rborges11@.hotmail.com> wrote in message
news:OlLOwtE1DHA.1336@.TK2MSFTNGP12.phx.gbl...
> I'm intending to create a stored procedure with a temporary table with
that
> values and use it as a result set.
> Is it possible to make it using EXECUTE (@.SQLCOMMAND) ?
> Does any body have another idea ?
>
You could possibly use sp_executesql|||Hi
Say if your temp table which contains sqls like,
select * from table
insert into table select * from k
delete from table2
Then you can use a cursor and dynamic sql,
1. Declare @.sql nvarchar(8000)
2. Declare and open the cursor with @.sql = column from temptable (Which
contains the sql statements)
3. exec sp_executesql @.sql
4. Fetch next sql statement , the cursor repeats till status becomes -1
Thanks
Hari
MCDBA
"Rodrigo" <rborges11@.hotmail.com> wrote in message
news:OlLOwtE1DHA.1336@.TK2MSFTNGP12.phx.gbl...
> Dears,
> I have a table with SQL Commands in it, and I want to create a result set
> with the values powered by these commands.
> I'm intending to create a stored procedure with a temporary table with
that
> values and use it as a result set.
> Is it possible to make it using EXECUTE (@.SQLCOMMAND) ?
> Does any body have another idea ?
> Thanks in advantage,
>
> Rodrigo.
>|||Dear Uri, Dan and Hari,
Thanks for your help. The solution works very well.
Rodrigo.
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:eO4mN3E1DHA.3216@.TK2MSFTNGP11.phx.gbl...
> Hi
> Say if your temp table which contains sqls like,
> select * from table
> insert into table select * from k
> delete from table2
> Then you can use a cursor and dynamic sql,
> 1. Declare @.sql nvarchar(8000)
> 2. Declare and open the cursor with @.sql = column from temptable (Which
> contains the sql statements)
> 3. exec sp_executesql @.sql
> 4. Fetch next sql statement , the cursor repeats till status becomes -1
> Thanks
> Hari
> MCDBA
>
> "Rodrigo" <rborges11@.hotmail.com> wrote in message
> news:OlLOwtE1DHA.1336@.TK2MSFTNGP12.phx.gbl...
> >
> > Dears,
> >
> > I have a table with SQL Commands in it, and I want to create a result
set
> > with the values powered by these commands.
> >
> > I'm intending to create a stored procedure with a temporary table with
> that
> > values and use it as a result set.
> >
> > Is it possible to make it using EXECUTE (@.SQLCOMMAND) ?
> >
> > Does any body have another idea ?
> >
> > Thanks in advantage,
> >
> >
> > Rodrigo.
> >
> >
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment