Gaps in Identity Range
Hi All,
We're experiencing a weird phenomenon with identity range management presently and wondered if anyone had any ideas on why it's happening and how to fix.
We are using Merge Replication and 5 subscribers.
When we look at the table that holds the identity ranges (i.e. range_begin, range_end, next_range_start and next_range_end) we see that there appears to be a big gap in the middle of the identity range on the constraint.
This is an example of what I mean...
([ID]>(13018108) AND [ID]<=(13118108) OR [ID]>(16818108) AND [ID]<=(16918108))
Anyone any ideas as to what caused this?
I understood that the primary and secondary ranges where allocated thus.
A --> B and B --> C
and not...
A -- B and X--> Y
If you see what I mean...
Warm Regards,
Nigel.
That is strange - they are supposed to be contiguous blocks. ie
([ID]>(13018108) AND [ID]<=(13118108) OR [ID]>(13118108)
AND [ID]<=(13218108))
Is this the case for both publisher and subscriber ranges? i.e. the primary and secondary ranges should be contiguous regardless of whether it is a publication database or subscriber database?
Let's assume the ranges on the publication database for a specific table are as follows:
([ID]>(13018108) AND [ID]<=(13118108) OR [ID]>(16818108) AND [ID]<=(16918108))
Let's also assume that the last ID used in the table is 13118108 and the ID column is being incremented by 1.
If an application tries to insert let's say 30 rows, I assume the insert would fail... Or, would the identity range constraint be automatically adjusted to allow the insert if the application was inserting as either the 'sa' user or as a member of the 'db_owner'
role?
Do you have any idea what might cause the gaps in the ranges?
Would you recommend reseeding the identity ranges?
Is manually editing the identity range check constraint an option?
Similar Messages
-
Hi All,
Iam generating batch numbers in my enhancement using number range. If I exit from the application there are gaps in the number range. Is there any alternative for this?
Thanks&Regards,
Manjula.SHi,
I need to generate the batches in the middle of my application.
Thanks&Regards,
Manjula.S -
Query to find numeric range gaps within another range
Hi All,
Is it possible to find the solution with a SQL query for the following scenario.
I have done it in PL/SQL but want to do it in SQL. I have tried with analytic functions but not able to find the expected results.
Suppose i have a Table A with below data
Range_Start Range_End
4 16
20 100
101 200
250 300
And Table B with below data
SubRange_Start SubRange_End
7 9
10 13
20 60
70 80
110 190
270 300
i want to find the missing gaps in Table B within the ranges specified in Table A, like below
Output
start end
4 6
14 16
61 69
81 100
101 109
191 200
250 269Hi Dear,
Can I do reverse I mean I can get output as your question from your output as below:
I have this table
FID STARTD ATE END DATE
1 01-MAY-10 03-MAY-10
1 09-MAY-10 11-MAY-10
1 03-JUN-10 04-JUN-10
2 03-JUN-10 04-JUN-10
2 04-AUG-10 04-AUG-10
2 06-AUG-10 06-AUG-10
I want like this.
FID FDATE
1 01-MAY-10
1 02-MAY-10
1 03-MAY-10
1 09-MAY-10
1 10-MAY-10
1 11-MAY-10
1 03-JUN-10
1 04-JUN-10
2 03-JUN-10
2 04-JUN-10
2 04-AUG-10
2 06-AUG-10
And:
How can i get date wise entry from Joining date to relieving date like..
FID START DATE END DATE
1 01-MAY-10 03-MAY-12
1 09-MAY-10 11-MAY-11
2 04-AUG-10 04-AUG-11
I want like this.
FID FDATE
1 01-MAY-10
1 03-MAY-10
1 04-MAY-10
1 05-MAY-10
1 16-MAY-10
1 17-MAY-10
1 08-May-10
1 09-May-10
1 03-May-12
Can you please help me.
Thanks,
Edited by: 978452 on Dec 24, 2012 12:02 AM -
Hello all,
I am getting the gaps in billing document no. ranges suppose my last invoice is of 100002 the my recent invoice no. is 100005 . how to minimise tese errors.
suggestHello
When there is a gap, it means that the number range is assigned to another document type also.
Please check the settings for document type to know if the number range is assigned.
If you do not want such gaps, ensure the number range is not assigned to any other document type
Reg
Suresh -
I was recently asked to help create a query at my company to search for date gaps in employment status history. My table data looks similar to this
employee_id employment_status beg_date end_date
1 Active 1990-01-01 1991-01-01
1 Leave 1991-02-01 1993-06-03
1 Active 1993-06-04 1995-02-01
1 Fired 2000-06-01 2299-12-31
So the gap im looking for would be from 1995-02-01 and 2000-06-01
Unfortunately as well, I dont have admin access to the database in order to be able to create an index, or do any fancy PL/SQL, im pretty much limited to the most basic SQL possible.
Any help appreciated!If your database supports analytic functions, the following query should give what you want.
with sample_data as (
select 1 employee_id, 'Active' employment_status, date '1990-01-01' beg_date, date '1991-01-01' end_date from dual union all
select 1, 'Leave', date '1991-02-01', date '1993-06-03' from dual union all
select 1, 'Active', date '1993-06-04', date '1995-02-01' from dual union all
select 1, 'Fired', date '2000-06-01', date '2299-12-31' from dual
select employee_id,
employment_status as last_status,
end_date as gap_lower_bound,
next_date as gap_upper_bound,
next_status
from
select t.*,
lead(beg_date) over(partition by employee_id order by beg_date) next_date,
lead(employment_status) over(partition by employee_id order by beg_date) next_status
from sample_data t
where next_date > end_date + 1
EMPLOYEE_ID LAST_STATUS GAP_LOWER_BOUND GAP_UPPER_BOUND NEXT_STATUS
1 Active 01/01/1991 01/02/1991 Leave
1 Active 01/02/1995 01/06/2000 Fired
Note #1 : the WITH clause is just there to generate some test data "on-the-fly", you can remove it and use your real table in place of SAMPLE_DATA in the main query.
Note #2 : unless you made a typo, the gap 01/01/1991 to 01/02/1991 should also be retrieved.
BTW, for specific questions about SQL or PL/SQL please use the {forum:id=75} forum.
Edited by: odie_63 on 27 févr. 2011 17:16 -
Gaps in billing document number range
Dear all,
Our SAP system is getting gaps in number range for billing document. I have checked the buffering status for number range its status is "No buffering".
SAMUNDER SINGHDear Customer,
In SD module, the gaps in invoice number may be caused normally due to
two reasons:
- update interruptions - the number is set in to the invoice at the
beggining of the program . If an interruption of the process happens
after the assignation of this number, the number has run in the range
and cannot be recovered. Update terminations in transaction VF01 and
VF04. The billing document number is reserved prior to the update.
After a possible update termination, it cannot be used again.
Update terminations are displayed in transaction SM13. At present,
is no possible solution.
- Object RV_BELEG is buffered. In this case the performace is improved
but this gaps are produced.
I am sorry to tell you that there is no way to solve the gaps or to
'refill' the missing invoice numbers.
There is a report RFBNUM00 that shows the gaps regarding the FI-
document numbers.
But for the SD invoice numbers you could do a hardcopy of the update
termination that caused the invoice number gap; this termination can
be seen in the syslog.
We know that in different countries you have to explain document gaps
to Legal Authorities.
For this reason there is report RFVBER00 to document gaps occured due
to an update termination. The report RFVBER00 does only list update
terminations that are not older than 50 days (or according to what time
is maintained in your system).
So it could be that this log has already been cleaned up.
It is necessary that these update terminations are documented before
the 50 days expire.
Or a second possibility is that the gaps occured NOT due to an update
termination.
Gaps without update terminations cannot be (easily) explained.
They can be (only) detected via report RFBNUM00.
Report RFBNUM00 displays these document number gaps for the number range
object RF_BELEG.
The only thing I can offer to you is to monitor the VBRK numbers
carefully.
To fulfill the legal requirements I would recommend to document the
number gaps but not to add any invoice numbers manually.
regards
Claudia -
To change the Transport Request Number Range.
<b>Hi Experts,</b>
My customer needs a typical solution.
He wants SAP to create the Future Transport Requests starting from 10000. ( Ten thousand)
now the sequential order is 321
that is <SID><K9>00321. From now on the new transport request should start from 10000
i.e.
<SID><K9>100000
<SID><K9>100001
<SID><K9>100002
etc.
Is it possible. ?
Thanks for your help.
Best Regards,
Raghunahth LHi
Check the report RSWBO301 and check its documentation..
Press "I" button in the selection screen to get the documentation..
I believe this might solve your problem...
Program documentation
Short text
Number Assignment for Requests: Find Free Interval
Description
This report program searches for a free interval for numbering requests.
If the search is successful, you can save the interval. The request
numbers are then taken from this interval.
Requirement
For customers the number range interval includes the follwing areas:
o 900000-999999 (just numerals)
o 9A0000-9ZZZZZ for ASCII character set or
9AAAAA-9Z9999 for EBSDIC character set.
You only need to execute this program if you have come to the end of the
number range interval, but there are still large gaps in the range that
you want to use up.
Example
Why you might get into this situation:
The customer has the R/3 System C11. The last number assigned is
C11K900115. The customer now imports transport request C11K9ZZZZA
from an external R/3 System C11 into the customer system C11. The
next request created in this system will have the number C11K9ZZZZB
Procedure
Proceed as follows:
1. Execute this program in transaction SE38.
2. Enter the interval limit, for example 5000. You can change this
limit at any time.
3. Choose Execute.
If you entered an interval limit of 5000, the report searches for a
free interval with a size of 5000.
4. If the search was successful, you can save this interval. If not,
repeat the search with a smaller interval.
Thanks,
Naren
Thanks,
Naren -
ITSM: Cancelled Change Documents - Number range goes missing
Hi Experts, We create RFCs, Urgent, Normal, Admin changes. however when we "create change record/change doc" a number is assigned to the record/doc. Sometimes we cancel and come out of the Creation process and then again restart our process. This time the number assigned to the previous record is lost and then a new number is assigned to the new record. This way a lot of the numbers goes missing in the sequence when you do a full search of all records/docs. Is there a way to get over this issue? please advise.
Hi,
try with after unchecking the "early numbering assignment" option in your ztransaction types.
follow here Configuring & Reducing Gaps in Number Range for IT Service Management
Thanks
Jansi -
Primary Key Violation at the time of Moving from primary range to secondary range.
Hi Experts,
I've observed a strange issue in our environment.
we are using sql server 2008 R2 with SP2.
whenever a table is moving from primary range to secondary range on it's identity values, application is getting crashed with the message as below.
Violation of PRIMARY KEY constraint 'PK6'. Cannot insert duplicate key in object 'dbo.TD_TRANN'. The duplicate key value is (17868679).
The statement has been terminated.
OR
Violation of UNIQUE KEY constraint 'IX_TDS_COST'. Cannot insert duplicate key in object 'dbo.TDS_COST'. The duplicate key value is (17, 19431201).
identity ranges were auto managed by replication. agents are running continuous.
please suggest.
Cheers, Vinod MalloluWell this is pretty simple, so there are two type of subscriptions (Server and client) in merge replication. So while adding article you provide following parameters:
@pub_identity_range
@identity_range
You can check the details of above parameters on following article:http://msdn.microsoft.com/en-us/library/ms174329.aspx
Snippet
@pub_identity_range= ]
pub_identity_range
Controls the identity range size allocated to a Subscriber with a server subscription when automatic identity range management is used. This identity range is reserved for a republishing Subscriber to allocate to its own Subscribers.
pub_identity_range is bigint, with a default of NULL. You must specify this parameter if
identityrangemanagementoption is auto or if
auto_identity_range is true.
[ @identity_range= ]
identity_range
Controls the identity range size allocated both to the Publisher and to the Subscriber when automatic identity range management is used.
identity_range is bigint, with a default of NULL. You must specify this parameter if
identityrangemanagementoption is auto or if
auto_identity_range is true.
So for example you are adding "Server" type subscription then we consider @pub_identity_range value while assigning the range to that sub. If it is "Client" type subscription in that case we consider @identity_range value.
You could run following query to check the range assigned to each publisher and subscriber:
SELECT B.SUBSCRIBER_SERVER,B.DB_NAME,A.* FROM MSMERGE_IDENTITY_RANGE A,SYSMERGESUBSCRIPTIONS B
WHERE A.SUBID=B.SUBID
This should answer your other question as well.
Vikas Rana | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker -------------------------------------------------------------------------------- This posting is provided "AS IS"
with no warranties, and confers no rights. ------------------------------------------------ -
Hi gurus,
can somebody give me a document on identity management.
Kind regards,
shruti beri rajatRequirement:
could you help me with a query to get all the tables with current identity ranges (example like 10000 or 20000 etc), and how frequently they are getting new ranges? etc.
Is it managed automatically or manually?
How to: Manage Identity Columns (Replication Transact-SQL Programming)
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
Object Number range "DEBITOR": NUMBER_GET_NEXT error overlaps
Hello,
I have an error with one of the number range belonging to the standard object "DEBITOR".
When we try to create a customer the system gives a old number already saved for another customer in database KNA1.
I know that this number range is buffered and we have gaps in number range used but
Why the system gives number already used?
For example: we have a rumber range from 5000000 to 5000199 and the last number used is 50000040.
When you create a new customer and the system runs the standard function NUMBER_GET_NEXT, it assigns the number 50000036.
Please, could you help me?
thanks in advance,
aupalaura
Edited by: aupalaura0 on Apr 23, 2010 12:17 PMHi,
Check whether the number ranges in question were initially made external and lateron were made to internal number range assignment.
Thanks
Aravind -
Hi Experts,
A very happy new year to all of you(to some in advance)!!
I have a table where I have the employee id and task assigned with start dates & end dates. Overlapping dates of tasks is a data issue however I know how to spot them & eradicate them. So there will be no overlapping task dates
Employee_id
Task_No
Task_Start_date
Task_End_Date
Sample Data
1 T1 01-Jan-2014 28-Feb-2014
1 T2 01-Mar-2014 31-Dec-2014
2 T1 23-Jan-2014 31-Dec-2014
2 T2 01-Jan-2015 31-Dec-2073 (Means end of time)
3 T3 01-Jan-2014 15-Jul-2014
3 T4 01-Aug-2014 31-Dec-2014
4 T5 01-Jan-2014 31-Dec-2073
I want to devise a query where i provide the end date & it will list out all the employees who are free for even one day starting 01-Jan-2014. So for example If I give 31-Dec-2014, it will list out
EmpId (First day on which the employee is free)
2 01-Jan-2014
3 16-Jul-2014
If I give end date = end of time(31-Dec-2013), Expected Result -
EmpId (First day on which the employee is free)
1 01-Jan-2015
2 01-Jan-2014
3 16-Jul-2014
If I give end date = 31 Jan 2014, Expected Result -
EmpId (First day on which the employee is free)
1 01-Jan-2015
I devised following query, however it does not catch employee id 2. Also it does not provide flexibility to change end date-
select *
from (select employee_id,
task_start_date,
task_end_date,
lag(task_end_date, 1, task_start_date) over(partition by employee_id order by task_start_date) prev_end_date
from shop.employee_tasks
where task_end_date >= trunc(sysdate))
where task_start_date - prev_end_date > 1
Thanks in advance!!
Regards,This is an example of what I call the "free time" query: you have the dates when you are busy and you want the dates when you are free.
You can find a beautiful solution to the basic problem here: Ask Tom "SQL Query to find gaps in date ranges" (search for Antony Boucher's solution). Please note that this solution works even with overlapping date ranges.
To apply the solution here, first create the test data (please do this yourself in later questions).
create table t(Employee_id, task_no, Task_Start_date, task_end_date)
as select
1, 'T1', to_date('01-jan-2014'), to_date('28-feb-2014') from dual union all select
1, 'T2', to_date('01-Mar-2014'), to_date('31-Dec-2014') from dual union all select
2, 'T1', to_date('23-jan-2014'), to_date('31-dec-2014') from dual union all select
2, 'T2', to_date('01-jan-2015'), to_date('31-dec-2073') from dual union all select
3, 'T3', to_date('01-jan-2014'), to_date('15-jul-2014') from dual union all select
3, 'T4', to_date('01-aug-2014'), to_date('31-dec-2014') from dual union all select
4, 'T5', to_date('01-Jan-2014'), to_date('31-Dec-2073') from dual;
In the query, you have to add records for yesterday and for the "end date" you want. This allows you to find "free time" before and after the date ranges in your table.
Now you partition by Employee_id and order by Task_Start_date. Using the max(task_end_date) analytic function, you get the latest end date up to now. Add 1 to this and you get the first free date (maybe). To make sure that date is free, it has to be before the next start date.
variable end_date varchar2(64)
exec :end_date := '31-Dec-2073';
with boundaries as (
select trunc(sysdate)-1 task_start_date, trunc(sysdate)-1 task_end_date from dual
union all
select to_date(:end_date)+1, to_date(:end_date)+1 from dual
), data as (
select * from t
where task_end_date >= trunc(sysdate)
and task_start_date < :end_date
union all
select distinct a.employee_id, null, b.task_start_date, b.task_end_date
from t a, boundaries b
select employee_id, min(free_start) free_start
from (
select employee_id,
max(task_end_date) over (partition by employee_id order by task_start_date)+1 free_start,
lead(task_start_date) over (partition by employee_id order by task_start_date)-1 free_end
from data
where free_start <= free_end
group by employee_id;
EMPLOYEE_ID
FREE_START
1
01-JAN-15
2
01-JAN-14
3
16-JUL-14 -
Identity seed at the subscriber changes automatically (SQL Server 2008 R2 SP2 CU9).
Hi all,
I have and updateable transactional subscription. The identity seed at subscriber for a table changed (I don't know how) and caused next inserts generate duplicate PKs. I manually reseeded (using DBCC CHECKIDENT) its identity column to upper value to prevent
duplicates. But after 5 seconds it is automatically reseeded to lower value. I repeated reseed command but again after sync with publisher it changed to lower value. How can I solve this problem?
Any help would be greatly appreciated.
LeilaIt is possible in this case that you are not syncing frequently enough, or that you are doing more than 2000 inserts on the subscriber between sync's. In this case you will need to change your subscriber identity range.
Right click on your publication, select properties, then in the articles tab, locate your table, click on article properties, and select set properties of highlighted table article, in the identity range management section , set subscriber range size to
some value like 2000 or 10000. 2000 will allow up to 4000 subscriber side inserts between syncs, and 10000 will allow 20,000 inserts on the subscriber.
looking for a book on SQL Server 2008 Administration?
http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X looking for a book on SQL Server 2008 Full-Text Search?
http://www.amazon.com/Pro-Full-Text-Search-Server-2008/dp/1430215941 -
HI Guru,
I have a question about gap in number range. Is it possible to set no gap in all mm documents such as PR, PO, Mat.Doc, Invoice doc?
may include material number and vendor number?
If they are possible to setup, please kindly help me to guide.
Thank you very much.Hi,
Kindly clarify what you mean by term GAP. Document number intervals are created for each year for different documents
to enable us to retrieve the data whenever we require and file and store it safely for future date. The numbers are
given in a systematic manner with different ranges to enable us to identify the nature of the document for example
no. starting from 1 will be invoice document and no. starting from 2 will be payment document. Now further number starting from 11 may be incoming invoice and 12 outgoing invoice. Likewise 21 will be incoming payment and 22 will be outgoing payment.
Regards,
Sadashivan -
Identity Management in a Pull Merge Replication at Subscriber
I am facing SQL Server Replication issue (Identity Management in a Pull Merge Replication at Subscriber).
Replication situation:
Distributor and the Publisher are in one server running Windows Server 2012 Std and SQL Server 2012 Std
One Subscriber PC running Windows 7 Professional and SQL Server 2012 Express Edition
Both are connected through the internet using VPN
The Problem:
Subscriber has an article (Table) [DocumentItems] where its Identity field [DocumentItemsID] is managed by Replication and was assigned the following range:
([DocumentItemsID]>(280649) AND [DocumentItemsID]<=(290649) OR [DocumentItemsID]>(290649) AND DocumentItemsID]<=(300649)
The server was disconnected from electricity several times. Every time the Subscriber PC is up, The [DocumentItemsID] field will pick an identity out of its range like 330035 when inserting new rows.
The issue happened 3 times. I fixed the problem by a manual reseed:
DBCC CHECKIDENT('DocumentItems' , RESEED, xxxx)
Where xxxx is the MAX existing value for [DocumentItemsID] + 1
Once the electricity is disconnected again, the same problem occurs.
Does anybody have any idea what is happening? And why the [DocumentItemsID] field was assigned values out of its range?
ThanksI am confused as to where/when this problem is happening.
From what you describe the publisher is disconnected from the subscriber by the power failure. During this time is your subscriber accepting data?
The subscriber will not increment it's range until it does a synchronization. Perhaps what is happening is that you have a power failure, and the subscriber is still running. It accepts inserts and eventually an insert is more than the assigned range. In
this case all inserts will fail until the subscriber syncs and after that the range in incremented. If these inserts are done in a batch, lets say 100,000 rows then entire batch will fail as it exceeds the possible identity values and then you will find that
your identity range is incremented even though the inserts failed.
What I would do is use manual identity range management and set your subscriber range manually to somehting high, or to have a -ve increment and a seed of 0.
looking for a book on SQL Server 2008 Administration?
http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X looking for a book on SQL Server 2008 Full-Text Search?
http://www.amazon.com/Pro-Full-Text-Search-Server-2008/dp/1430215941
Maybe you are looking for
-
I finally allowed the last update to run... upon completion, my browser window would not open. I rebooted, got the window to open but had no function on the navigation bar. The only way I could navigate the web was to go to my home page, google, sear
-
MX2004 can no longer launch on new hard drive
I've been using Dreamweaver MX 2004 for a while. Ran fine; could do all my work, no problem. Recently the hard drive on my laptop crashed and I installed a new one; moved all data over and 98% of my apps work fine. Dreamweaver is another story. At fi
-
Convert varchar in db to boolean
The dba's have modelled a field as a varchar(1), with valid values being 'Y' and 'N'. Can i map this as boolean within the Java class? thanks, craig
-
Lightroom 2.5 Workflow - Multiple Users
Cheers! But not so much for me. I am befuddled. Here is the scenario: I have more than one lightroom user on more than one desktop that needs to be able to work with the same set of images from a photo shoot. The images are on a network drive bu
-
What is a factory calendar in MM?
where it is configured and how the functionality works?