Friday, February 17, 2012

different behavior

I have an application (userx is the username) that creates tables on two
different databases. However when it creates it on the first database, it
creates it 'dbo.table1', whereas on the second database it creates the same
table named 'userx.table1'. We captured the script that creates the table
and it is "create table table1 ..."
Is there a setting that determinies what the name qualifier is by default.
We sat with the dba and we could not find any differences in the
configuration of the two databases.
Thanks,
Ericuserx is probably a member of the dbo role in the first database, but not th
e
second.
HTH
Vern Rabe
"Eric Stott" wrote:

> I have an application (userx is the username) that creates tables on two
> different databases. However when it creates it on the first database, it
> creates it 'dbo.table1', whereas on the second database it creates the sam
e
> table named 'userx.table1'. We captured the script that creates the table
> and it is "create table table1 ..."
> Is there a setting that determinies what the name qualifier is by default.
> We sat with the dba and we could not find any differences in the
> configuration of the two databases.
> Thanks,
> Eric
>
>|||If you want all tables to be owned by dbo, then your CREATE statement should
explicitly say so, e.g.,
CREATE TABLE dbo.TableName ...
HTH
Vern Rabe
"Eric Stott" wrote:

> I have an application (userx is the username) that creates tables on two
> different databases. However when it creates it on the first database, it
> creates it 'dbo.table1', whereas on the second database it creates the sam
e
> table named 'userx.table1'. We captured the script that creates the table
> and it is "create table table1 ..."
> Is there a setting that determinies what the name qualifier is by default.
> We sat with the dba and we could not find any differences in the
> configuration of the two databases.
> Thanks,
> Eric
>
>|||I am assuming you are running SQL 2000. Please always state your version in
the future.
Are you sure userx is the user name? Or is it the login name.
A login name gets you into SQL Server, but then when you use a database, you
login name is mapped to a username. Sometimes the names look the same,
sometimes they don't.
SELECT suser_sname() shows you your login name for the server
SELECT user_name() shows you your user name in the current database.
The only way to have a table owned by dbo without specifying the owner name
is to have your user name by dbo. Even if you are in the db_owner role, the
default will be that your real user name will be the owner of the table, and
you would have to ask to create a table dbo.table1.
My guess is that userx is a login name, and is the owner of one database but
not the other, or is aliased to the name dbo.
HTH
Kalen Delaney, SQL Server MVP
"Eric Stott" <eric@.stottcreations_nospam.com> wrote in message
news:eyKJO8yjGHA.5108@.TK2MSFTNGP02.phx.gbl...
>I have an application (userx is the username) that creates tables on two
>different databases. However when it creates it on the first database, it
>creates it 'dbo.table1', whereas on the second database it creates the same
>table named 'userx.table1'. We captured the script that creates the table
>and it is "create table table1 ..."
> Is there a setting that determinies what the name qualifier is by default.
> We sat with the dba and we could not find any differences in the
> configuration of the two databases.
> Thanks,
> Eric
>|||Yes it is SQL 2000, and no, we cannot change the script, it is created by an
application that we do not own.
I will look into which is the owner and which one is aliased...
Eric
"Kalen Delaney" <replies@.public_newsgroups.com> wrote in message
news:e22wt$zjGHA.1320@.TK2MSFTNGP04.phx.gbl...
>I am assuming you are running SQL 2000. Please always state your version in
>the future.
> Are you sure userx is the user name? Or is it the login name.
> A login name gets you into SQL Server, but then when you use a database,
> you login name is mapped to a username. Sometimes the names look the same,
> sometimes they don't.
> SELECT suser_sname() shows you your login name for the server
> SELECT user_name() shows you your user name in the current database.
> The only way to have a table owned by dbo without specifying the owner
> name is to have your user name by dbo. Even if you are in the db_owner
> role, the default will be that your real user name will be the owner of
> the table, and you would have to ask to create a table dbo.table1.
> My guess is that userx is a login name, and is the owner of one database
> but not the other, or is aliased to the name dbo.
> --
> HTH
> Kalen Delaney, SQL Server MVP
>
> "Eric Stott" <eric@.stottcreations_nospam.com> wrote in message
> news:eyKJO8yjGHA.5108@.TK2MSFTNGP02.phx.gbl...
>

No comments:

Post a Comment