PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > SQL Server 2005 default schema doesn't appear to be working
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
SQL Server 2005 default schema doesn't appear to be working

Réponse
 
LinkBack Outils de la discussion
Vieux 13/06/2008, 01h04   #1
ajwhite@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut SQL Server 2005 default schema doesn't appear to be working

Hi,

I'm currently testing SS2005 (the free version, Express I believe) for
work and I am trying to use the default schemas to mimic the
search_path ability of Postgres but it doesn't seem to be working.
For example:

=========================================
alter user my_user with default_schema = dbo
go
create schema my_schema
go
alter user my_user with default_schema = my_schema
go
create table old_users(id int, user_name varchar(255))
go
=========================================

My understanding is that this would create a table called "old_users"
in the "my_schema" schema. However when I look the table that gets
created is "dbo.old_users". I'm obviously missing something but I can
see what.

Thanks in advance for you ! (and sorry if this has been posted
before, I seached through the groups and on Google and haven't found
anything particularly ful yet)
  Réponse avec citation
Vieux 13/06/2008, 02h17   #2
Dan Guzman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SQL Server 2005 default schema doesn't appear to be working

> My understanding is that this would create a table called "old_users"
> in the "my_schema" schema. However when I look the table that gets
> created is "dbo.old_users". I'm obviously missing something but I can
> see what.


What user is executing this script? If you login as 'my_user' or change the
security context with EXECUTE AS, I would expect the table to be created in
the default schema as long has 'my_user has create permissions:

GRANT ALTER ON SCHEMA::my_schema TO my_user;
GO
EXECUTE AS USER = 'my_user';
GO
CREATE TABLE old_users(id int, user_name varchar(255));
GO

--
Hope this s.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

<ajwhite@gmail.com> wrote in message
news:613338f2-03b4-4623-aff9-7a89a35acbec@t54g2000hsg.googlegroups.com...
> Hi,
>
> I'm currently testing SS2005 (the free version, Express I believe) for
> work and I am trying to use the default schemas to mimic the
> search_path ability of Postgres but it doesn't seem to be working.
> For example:
>
> =========================================
> alter user my_user with default_schema = dbo
> go
> create schema my_schema
> go
> alter user my_user with default_schema = my_schema
> go
> create table old_users(id int, user_name varchar(255))
> go
> =========================================
>
> My understanding is that this would create a table called "old_users"
> in the "my_schema" schema. However when I look the table that gets
> created is "dbo.old_users". I'm obviously missing something but I can
> see what.
>
> Thanks in advance for you ! (and sorry if this has been posted
> before, I seached through the groups and on Google and haven't found
> anything particularly ful yet)


  Réponse avec citation
Vieux 16/06/2008, 23h55   #3
ajwhite@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SQL Server 2005 default schema doesn't appear to be working

On Jun 12, 8:17pm, "Dan Guzman" <guzma...@nospam-
online.sbcglobal.net> wrote:
> > My understanding is that this would create a table called "old_users"
> > in the "my_schema" schema. However when I look the table that gets
> > created is "dbo.old_users". I'm obviously missing something but I can
> > see what.

>
> What user is executing this script? If you login as 'my_user' or changethe
> security context with EXECUTE AS, I would expect the table to be created in
> the default schema as long has 'my_user has create permissions:
>
> GRANT ALTER ON SCHEMA::my_schema TO my_user;
> GO
> EXECUTE AS USER = 'my_user';
> GO
> CREATE TABLE old_users(id int, user_name varchar(255));
> GO
>
> --
> Hope this s.
>
> Dan Guzman
> SQL Server MVPhttp://weblogs.sqlteam.com/dang/
>
> <ajwh...@gmail.com> wrote in message
>
> news:613338f2-03b4-4623-aff9-7a89a35acbec@t54g2000hsg.googlegroups.com...
>
>
>
> > Hi,

>
> > I'm currently testing SS2005 (the free version, Express I believe) for
> > work and I am trying to use the default schemas to mimic the
> > search_path ability of Postgres but it doesn't seem to be working.
> > For example:

>
> > =========================================
> > alter user my_user with default_schema = dbo
> > go
> > create schema my_schema
> > go
> > alter user my_user with default_schema = my_schema
> > go
> > create table old_users(id int, user_name varchar(255))
> > go
> > =========================================

>
> > My understanding is that this would create a table called "old_users"
> > in the "my_schema" schema. However when I look the table that gets
> > created is "dbo.old_users". I'm obviously missing something but I can
> > see what.

>
> > Thanks in advance for you ! (and sorry if this has been posted
> > before, I seached through the groups and on Google and haven't found
> > anything particularly ful yet)- Hide quoted text -

>
> - Show quoted text -


Sweet, that worked! I should probably do some reading to understand
which (if not both) part b/t the grant and execute fixed my issues but
for now I'm just glad to get things working!


Thanks,

Andrew
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h38.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09716 seconds with 11 queries