all groups > sql server programming > november 2005 >
You're in the

sql server programming

group:

Table Name


Table Name Justin
11/25/2005 6:38:05 PM
sql server programming:
Hello,

I am new at programming using a SQL Server back-end and it hasn't taken me
long to run into some trouble...any help would be appreciated.

When tables are imported by users, the table names are
[username].[tablename] (for example, Jennifer.tblCustomers)...when I try to
reference the table using the [tablename], it doesn't work. But, when I use
the [username].[tablename], it works. Is there a way to make all tables that
are imported dbo.[tablename]? This scenario seems to work best b/c it would
make the 'prefix' standard for all tables throughout the database.

Thank you for any help you can offer.

Re: Table Name Tom Moreau
11/25/2005 9:58:06 PM
You can rename a table with sp_rename. Perhaps the import process can be
changed to create the table with owner dbo and you can avoid the problem at
the source.

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com

[quoted text, click to view]

Re: Table Name Erland Sommarskog
11/27/2005 12:12:46 AM
Justin (Justin@discussions.microsoft.com) writes:
[quoted text, click to view]

Tom suggested using sp_rename, but that may only work if you are in
Canada. :-)

In the rest of the world sp_changeobjectowner may be a better bet.

Of course, changing the import process may be an option, but without
knowing anything about your import process, it's difficult to say
whether this can be achieved or not. If the import process creates
tables, this would require users create tables owned by dbo, which
has some security implications.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
RE: Table Name Damien
11/27/2005 6:03:05 AM
You probably shouldn't have users creating tables in your database. Really
only the DBA or developers should be creating tables in order to maintain
some kind of integrity and control over the data. Are you creating
relationships for them, or proper indexes?

If your users do have to import large volumnes of data, why not INSERT into
an existing table?

Having said that, if when creating a table you prefix it with the owner it
will be created as such eg :

CREATE TABLE dbo.customers ...

There's no guaranteeing your users will have SELECT permissions on tables
created this way, but that's a separate issue.

Strictly speaking you should always prefix your objects with the database
name and the owner; this is called three-part naming;

eg northwind.dbo.users

Just out of interest, what does your DBA think of your database design?


Damien


[quoted text, click to view]
Re: Table Name Tom Moreau
11/27/2005 7:44:21 AM
Duh! I really need a coffee.

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
[quoted text, click to view]

Tom suggested using sp_rename, but that may only work if you are in
Canada. :-)

In the rest of the world sp_changeobjectowner may be a better bet.

Of course, changing the import process may be an option, but without
knowing anything about your import process, it's difficult to say
whether this can be achieved or not. If the import process creates
tables, this would require users create tables owned by dbo, which
has some security implications.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Re: Table Name Justin
11/29/2005 8:22:08 AM
Thank you all for your responses! Sorry I haven't checked in on this for a
while. I'm going try your suggestions and I'll get back with you.

THANKS!

[quoted text, click to view]
AddThis Social Bookmark Button