Friday, March 9, 2012

Problems with droping and creating tables

Hi
The case:
User execute a bat file that executes a sql script. This script drops a
number of tables, generate new tables and fills the new tables with data.
The problem:
The new tables that's created is created with the user executing the scripts
as owner, not dbo. Initially dbo was owner of the tables that where dropped.
The user is member of a a.d security group that is granted as a login on the
SQL server, and is dbo on the database in question.
If we run the script from a user that is member of the local admin group on
the server, SQL server sysadmin and dbo on the database, dbo is owner of the
new tables.
How can I resolve this issue? When the script is executed by the user I want
dbo to be owner of the table, specially since the user is member of a group
that is dbo on the specific database.
/A.What version of SQL Server?
If 2005, then specify the desired schema for the user in question.
If 2000, then make sure that your users specify the apropriate owner when they create the table, as
in:
CREATE TABLE dbo.myTable(...)
Also, just fyi (a remark about terminology):
> The user is member of a a.d security group that is granted as a login on the SQL server, and is
> dbo on the database in question.
Only one login can be the dbo. Other logins can have users who in the database have the db_owner
role, whcih gives the same permission as dbo has.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Andy.I" <Andy.I@.community.nospam> wrote in message
news:44DA00F1-BEA7-49CE-B7A5-E23D79077293@.microsoft.com...
> Hi
> The case:
> User execute a bat file that executes a sql script. This script drops a number of tables, generate
> new tables and fills the new tables with data.
> The problem:
> The new tables that's created is created with the user executing the scripts as owner, not dbo.
> Initially dbo was owner of the tables that where dropped.
> The user is member of a a.d security group that is granted as a login on the SQL server, and is
> dbo on the database in question.
> If we run the script from a user that is member of the local admin group on the server, SQL server
> sysadmin and dbo on the database, dbo is owner of the new tables.
> How can I resolve this issue? When the script is executed by the user I want dbo to be owner of
> the table, specially since the user is member of a group that is dbo on the specific database.
> /A.|||Thanks
I'll give it a try.
/A
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OMYDKMLEIHA.3548@.TK2MSFTNGP06.phx.gbl...
> What version of SQL Server?
> If 2005, then specify the desired schema for the user in question.
> If 2000, then make sure that your users specify the apropriate owner when
> they create the table, as in:
> CREATE TABLE dbo.myTable(...)
>
> Also, just fyi (a remark about terminology):
>> The user is member of a a.d security group that is granted as a login on
>> the SQL server, and is dbo on the database in question.
> Only one login can be the dbo. Other logins can have users who in the
> database have the db_owner role, whcih gives the same permission as dbo
> has.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Andy.I" <Andy.I@.community.nospam> wrote in message
> news:44DA00F1-BEA7-49CE-B7A5-E23D79077293@.microsoft.com...
>> Hi
>> The case:
>> User execute a bat file that executes a sql script. This script drops a
>> number of tables, generate new tables and fills the new tables with data.
>> The problem:
>> The new tables that's created is created with the user executing the
>> scripts as owner, not dbo. Initially dbo was owner of the tables that
>> where dropped.
>> The user is member of a a.d security group that is granted as a login on
>> the SQL server, and is dbo on the database in question.
>> If we run the script from a user that is member of the local admin group
>> on the server, SQL server sysadmin and dbo on the database, dbo is owner
>> of the new tables.
>> How can I resolve this issue? When the script is executed by the user I
>> want dbo to be owner of the table, specially since the user is member of
>> a group that is dbo on the specific database.
>> /A.
>

No comments:

Post a Comment