This is a discussion on Can we rely on object_id always increasing? within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi, When we create new user objects, can we assume that the object_id will constantly increase? In other words, ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, When we create new user objects, can we assume that the object_id will constantly increase? In other words, if I create a table and then a view, is it true that the object_id of the view if I query sysobjects view will be greater than the object_id of the table? Thanks! |
| |||
| On Mar 4, 11:33*am, czytacz <redak...@dupa.gazeta.pl> wrote: > no, > if you: > > 1) create table A > 2) create view V basis on A > 3) drop table A > 4) create table A (new 'A', the same name as A) > > the new A table will have bigger objectID than view V What you're saying then is that objects created will have an ever- increasing object_id, right? Meaning, ordering by create_date is the same as ordering by object_id....correct? Thanks! |
| |||
| On 4 Mar, 19:10, rajigo...@gmail.com wrote: > Hi, > > When we create new user objects, can we assume that the object_id will > constantly increase? In other words, if I create a table and then a > view, is it true that the object_id of the view if I query sysobjects > view will be greater than the object_id of the table? > > Thanks! Why would you want to assume that though? Even if it were true that object_id matched creation order it's still a dangerous assumption. Some people use the Management Studio UI to make modifications to objects and Management Studio will sometimes drop and recreate objects and sometimes not. I don't condone the use of Management Studio in this way but it does explain why the object_id might increment unexpectedly - or perhaps fail to increment when you expect it to. -- David Portas |
| ||||
| (rajigopal@gmail.com) writes: > When we create new user objects, can we assume that the object_id will > constantly increase? In other words, if I create a table and then a > view, is it true that the object_id of the view if I query sysobjects > view will be greater than the object_id of the table? It does not seem so. I ran this query on a database that I have: select name, crdate, id from sysobjects where type = 'U' order by crdate Output: abaconfigproperties 2008-02-03 19:36:39.107 1977058079 abaconfigsettings 2008-02-03 19:36:39.153 2009058193 abahistsysobjects 2008-02-03 19:36:39.217 2073058421 abainstallhistory 2008-02-03 19:36:39.293 2105058535 abaobjecttypes 2008-02-03 19:36:39.357 5575058 abasslabels 2008-02-03 19:36:39.403 37575172 abasubsystems 2008-02-03 19:36:39.450 85575343 abasysobjects 2008-02-03 19:36:39.513 133575514 -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |