Using Sqlserver 2000. We recently changed the ownership of a database using
sp_changedbowner 'new_owner', true. According to BOL, when the second
argument is true, the existing dbo alias for that database should be remappe
d
to new_owner. Although the database ownership did change to new_owner, the
Users display still shows dbo mapped to the old owner. Am I using
sp_changedbowner correctly? How do I remap the dbo user in that database to
the new owner?
--
MunchingBillThe login specified as the new dbowner should get mapped as the new 'dbo'
user regardless of the @.map specification. Did you refresh Enterprise
Manager?
Note that the @.map parameter indicates that existing *aliases* are remapped.
The dbo user is always remapped to the specified login. Aliases are a
backwards compatibility feature that allows multiple logins to be mapped to
the same database user.
Hope this helps.
Dan Guzman
SQL Server MVP
"MunchingBill" <munchingbill@.newsgroups.nospam> wrote in message
news:8FBEDA24-8F33-4FD7-BE5C-BE9B318D305C@.microsoft.com...
> Using Sqlserver 2000. We recently changed the ownership of a database
> using
> sp_changedbowner 'new_owner', true. According to BOL, when the second
> argument is true, the existing dbo alias for that database should be
> remapped
> to new_owner. Although the database ownership did change to new_owner, the
> Users display still shows dbo mapped to the old owner. Am I using
> sp_changedbowner correctly? How do I remap the dbo user in that database
> to
> the new owner?
> --
> MunchingBill
Showing posts with label alias. Show all posts
Showing posts with label alias. Show all posts
Monday, March 26, 2012
Friday, March 23, 2012
How to reference a previous field Alias in TSQL as in Jet SQL?
My question is simple, I'd like to do something I do in Jet ANSI-89 SQL. Mind you I'm just adding numbers here - they are not actual columns in 'SomeTable'
SELECT 1 AS A, 2 AS B, A+B AS C
FROM SomeTable
The Jet engine evaluates and does arithmetic on the Aliased column names - handy when they contain their own functions. The resultset would show:
A B C
1 2 3
However from what I can tell SQL Server 2005 is not picking this up. Is their an equivalent?
The Jet syntax is non-standard SQL syntax so it will not work in SQL Server. You will have to use a derived table or CTE (in SQL Server 2005) or use a view or computed column in the table (if the expression involves columns from a single table).
select A, B, A+B as C
from (select 1 as A, 2 as B
from sometable
) as t
with t as (
select 1 as A, 2 as B
from sometable
)
select A, B, A+B as C
from t
Subscribe to:
Posts (Atom)