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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Default Table/Object Owners

Author  Topic 

davidpardoe
Constraint Violating Yak Guru

324 Posts

Posted - 2002-03-22 : 07:08:19
Is there a global setting that specifies who the default owner of an object is if it is not explicitly specified?

For example in our installation if I am logged in as user david and create an object:-
CREATE TABLE test (test int)
then the owner of the table test is dbo.

Is there a setting so that the owner is automatically david (without explicitly referencing it)?

============================
Chairman of
The NULL Appreciation Society
"Keep NULLs as NULL"

jackstow
Posting Yak Master

160 Posts

Posted - 2002-03-22 : 07:34:23
Is it not the case that if user david is down as db owner for that database then dbo.test and david.test are one and the same thing anyway?

Go to Top of Page

davidpardoe
Constraint Violating Yak Guru

324 Posts

Posted - 2002-03-22 : 07:41:30
The problem is that I have a stored procedure that creates several tables and then subsequently drops them. In doing so I need to make sure that the drop statement references the correct user (david or dbo). We know that on our SQL Server dbo is used but on another server david is used.

Before you (or anybody else!) mentions it - I could change the created tables to temporary tables which would get around this (or explicitly attach them to the user david) but I am keen to know the answer to the question anyway.

============================
Chairman of
The NULL Appreciation Society
"Keep NULLs as NULL"
Go to Top of Page

davidpardoe
Constraint Violating Yak Guru

324 Posts

Posted - 2002-03-28 : 05:40:43
Just to add to this (given the reference from another thread - http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=14321)...

The stored procedure described above when run from QA under the david login creates the tables with owner dbo. When run via ASP from a web page the tables are created with owner david.

Why???



============================
Chairman of
The NULL Appreciation Society
"Keep NULLs as NULL"
Go to Top of Page

dsdeming

479 Posts

Posted - 2002-03-28 : 07:57:15
Take a look at the SYSTEM_USER function. You may have to trim a domain name off of the user name, but if your sql user names match network user names, you should be able to dynamically create and drop your table without any confusion over ownership.

Go to Top of Page
   

- Advertisement -