Saturday, February 25, 2012

changing object owner syntax

Hi there,
We have a user name convention here that specifies users in the
following way:
jane.doe
john.smith

In order to change a database object I must specify the owner name along
with the object name. Does anyone know the proper syntax for doing this
with a user name that contains a period? When I put the user name
followed by the object name in quotes such as 'jane.doe.tb_test_table',
SQL Server can not find the object.
Any help is appreciated.
Kelly"Kelly Prendergast" <kelly.prendergast@.noaa.gov> wrote in message
news:403B9200.6882586F@.noaa.gov...
> Hi there,
> We have a user name convention here that specifies users in the
> following way:
> jane.doe
> john.smith
> In order to change a database object I must specify the owner name along
> with the object name. Does anyone know the proper syntax for doing this
> with a user name that contains a period? When I put the user name
> followed by the object name in quotes such as 'jane.doe.tb_test_table',
> SQL Server can not find the object.
> Any help is appreciated.
> Kelly

You will need to quote the owner name:

exec sp_changeobjectowner '[jane.doe].tb_test_table', 'dbo'

You may want to consider changing your naming convention - since the .
character delimits object name parts in MSSQL, it would probably be best to
avoid confusiong by not allowing it in user names. Although of course I
appreciate this may be beyond your control.

Simon

No comments:

Post a Comment