October 27, 2015 at 2:05 am
Hello,
I have 2 tables:
1 is with only one field: numerator
2ed is (for example) sales information.
I need to export (using SP) the sales information with unique numerator per line.
So,
I need to get the value from table 1 (numerator),
I need to promote the numerator by 1 for every line,
and I need to update the first table (numerator) (as i need to keep it updated for the next run).
at the next run I need to get again the updated numerator from the first table, and so on...
How do I do taht ?
Many thanks in advance !
October 27, 2015 at 2:52 am
sql_u (10/27/2015)
Hello,I have 2 tables:
1 is with only one field: numerator
2ed is (for example) sales information.
I need to export (using SP) the sales information with unique numerator per line.
So,
I need to get the value from table 1 (numerator),
I need to promote the numerator by 1 for every line,
and I need to update the first table (numerator) (as i need to keep it updated for the next run).
at the next run I need to get again the updated numerator from the first table, and so on...
How do I do taht ?
Many thanks in advance !
Sounds a little over-engineered. Why not store the last "numerator" used in the sales information export instead? Some simple arithmetic and @@ROWCOUNT would make this very cheap to do. It would also give you a starting point for a batch export log table.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 27, 2015 at 3:03 am
Hi,
The export table, is actually a temp table (contains some data from other joined tables).
What I actually need is to set the seed of identity in my stored procedure.
So I will select the last numerator - and set the seed.
This should do the work, But how do I do that... ?
(any other solution will be good as well).
Thanks for your time.
October 27, 2015 at 3:21 am
sql_u (10/27/2015)
Hi,The export table, is actually a temp table (contains some data from other joined tables).
What I actually need is to set the seed of identity in my stored procedure.
So I will select the last numerator - and set the seed.
This should do the work, But how do I do that... ?
(any other solution will be good as well).
Thanks for your time.
DBCC RESEED will do that for you.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply