all groups > sql server programming > march 2007 >
You're in the

sql server programming

group:

Getting rows in TempTable After QueryBatch


Re: Getting rows in TempTable After QueryBatch M A Srinivas
3/22/2007 10:21:31 AM
sql server programming:
On Mar 22, 9:46 pm, "Sugandh Jain" <sugandh.j...@nirvana-sol.com>
[quoted text, click to view]

You may require a logic like identity column or time stamp. Before
executing the SP , findout the max(id) from the table.
After SP is completed
select * from into newtable from yourtable where id >max(id)

Re: Getting rows in TempTable After QueryBatch Aaron Bertrand [SQL Server MVP]
3/22/2007 1:32:11 PM
SInce you are already using dynamic SQL and passing in a whole string as a
batch, assuming you have:

SET @OriginalQuery = 'insert table_name(blah) select ''foo'';
insert table_name(blah) select ''bar'';
insert table_name(blah) select ''blat'';'

SET @OriginalQuery = @OriginaQuery + REPLACE(@OriginalQuery, 'table_name(',
'#temp_table_name(');

--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006








[quoted text, click to view]

Getting rows in TempTable After QueryBatch Sugandh Jain
3/22/2007 10:16:36 PM
Hi,

I have a number of insert queries running in a batch on a single table.
This query batch is passed to the stored procedure as a dynamic sql.

I want to have all the rows that are inserted in this batch in a separate
temp table with the same table structure as the parent table.

how to get this?

Regards,
Sugandh

AddThis Social Bookmark Button