Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2013-03-27 : 03:49:06
|
Hi,this might look stupid but will db_id and object_id crash one day? What i trying to say that, will the value return might get same in any possible?for example:select DB_ID(N'AdventureWorksDW2012')return 1select OBJECT_ID(N'AdventureWorksDW2012.dbo.DimAccount')return 1 |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-03-27 : 09:10:41
|
It certainly is possible. When I run the query "select MIN(object_id) from sys.objects" on my test server it returns 3. The object name is sysrscols. On my server db_id = 3 is model database. |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2013-03-27 : 10:58:38
|
Sorry, my bad. further clarificationselect object_id(table_name) from INFORMATION_SCHEMA.TABLESdatabase id vs table id |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-03-27 : 11:52:47
|
I don't know the answer to this - but I would think that the algorithms ued to determine the range of values for user tables is something internal to Microsoft and it would not be a good idea to rely on it being in any particular range. For example, see this page regarding temp tables http://blogs.msdn.com/b/psssql/archive/2012/09/09/revisiting-inside-tempdb.aspx |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2013-03-27 : 12:00:24
|
If you're asking if object_id() and db_id() can return the same value, then the answer is a definite yes.What are you trying to accomplish? Why do you care what the object_id or database_id is? You can always derive it when needed to pass as a parameter.If you're creating objects SQL Server will assign object ids.If you're searching for objects, you can identify them by name and/or type. |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2013-03-31 : 12:49:05
|
im just curious about is there any unique identifier for database and table and will they crash each other? =P |
|
|
|
|
|