Wednesday, March 7, 2012

process result recordset from storedproc

hi!
I have a stored proc which aggregates some values and
returns a recordset with one record
...looking something like this:
val1 val2 val3
-- -- --
24723 26457 342579
how can I use this record for further processing
e.g. write it into an existing table (for logging)
hmm, this is probably a newbie-question
but I couldnt find the answer in BOL...
any help is greatly appreciated,
best regards,
haraldIf you want to handle only one record you can use variables to store and use
it.
For eg:
Declare @.Val1 int , @.Val2 int ...
Select @.Val1 = Val1, @.Val2 = Val2 etv...
Insert into TableName (@.Val1, @.val2 etc..
Other wise you can use a cursor for looping it.
Please refer books online.
Thank you
Baiju
"Harald Peki" <mabuse007@.yahoo.com> wrote in message
news:1109832522.363076@.news.liwest.at...
> hi!
> I have a stored proc which aggregates some values and
> returns a recordset with one record
> ...looking something like this:
> val1 val2 val3
> -- -- --
> 24723 26457 342579
> how can I use this record for further processing
> e.g. write it into an existing table (for logging)
>
> hmm, this is probably a newbie-question
> but I couldnt find the answer in BOL...
> any help is greatly appreciated,
> best regards,
> harald
>
>|||hello baiju,
thanks very much - I am aware of cursors, but hoped there would be a
easier and more elegant solution.
generally asked: isnt there a way to use the storedproc-recordset in the
same
way like the resultset of a function which returns a table?
I this case I can use a statement like this:
INSERT INTO StatsTables
SELECT * FROM dbo.adm_CountAllTables_function()
...where dbo.adm_CountAllTables_function() is - obviously ;))) - a
function...
hmm, I guess it IS the most usefull solution to change the storedproc to a
function.
Im most thankful for any further comments.
best regards,
harald
"Baiju" <baiju@.indus-systems.com> schrieb im Newsbeitrag
news:uhfN$f8HFHA.4032@.TK2MSFTNGP12.phx.gbl...
> If you want to handle only one record you can use variables to store and
use
> it.
> For eg:
> Declare @.Val1 int , @.Val2 int ...
> Select @.Val1 = Val1, @.Val2 = Val2 etv...
> Insert into TableName (@.Val1, @.val2 etc..
>
> Other wise you can use a cursor for looping it.
> Please refer books online.
>
> Thank you
> Baiju
>
> "Harald Peki" <mabuse007@.yahoo.com> wrote in message
> news:1109832522.363076@.news.liwest.at...
>|||use
insert into table_name
exec proc_name
"Harald Peki" wrote:

> hi!
> I have a stored proc which aggregates some values and
> returns a recordset with one record
> ...looking something like this:
> val1 val2 val3
> -- -- --
> 24723 26457 342579
> how can I use this record for further processing
> e.g. write it into an existing table (for logging)
>
> hmm, this is probably a newbie-question
> but I couldnt find the answer in BOL...
> any help is greatly appreciated,
> best regards,
> harald
>
>|||hi tom!

> insert into table_name
> exec proc_name
oops! great!!!
...but funny...tried that one but obviously had some syntax mistake or
something...
WORKS GREAT NOW!!
Thanks very, very much!
all systems up and running ;))
best regards,
harald
"Tomasz Borawski" <TomaszBorawski@.discussions.microsoft.com> schrieb im
Newsbeitrag news:4895E3C4-C967-46BB-99F4-54724C98CE71@.microsoft.com...
> use
> insert into table_name
> exec proc_name
>
> "Harald Peki" wrote:
>

No comments:

Post a Comment