Showing posts with label dbo. Show all posts
Showing posts with label dbo. Show all posts

Friday, March 30, 2012

No Lock

Lets say i have a view.

vuTestingNoLocks

this view looks like this...

Create View vuTestingNoLocks as

SElect *

From dbo.Employees

inner Join dbo.EmployeeTerritories on EmployeeTerritories.EmployeeID = Employees.EmployeeID

If I select from this view using Select * From vuTestingNoLocks (NOLOCK)

Does the (nolock) command propegate down through the tables? Meaning will it scan tables that are locked still ignoring their locks?

I think you should be able to test it out and come to your own conclusions. Let me know what you are going to interpret from this.

In one window, create these tables, populate dummy data and create the view

Code Snippet

--Start of window1

create table t1 (t1id int identity(10,10),

t1code char(2)

)

create table t2 (t2id int,

t2name varchar(10)

)

insert t1 select 'AB'

insert t1 select 'BC'

insert t1 select 'CD'

insert t2 select 10, 'Group AB'

insert t2 select 20, 'Group BC'

insert t2 select 30, 'Group CD'

create view vw_t1_t2 as

select t1id, t1code, t2name

from t1 join t2

on t1.t1id = t2id

--End of window1

--start of window2

--we are setting up to take exclusive lock

begin tran

update vw_t1_t2

set t1code = 'KK'

--end of window2

--start of window3

--Issue this once

select * from vw_t1_t2 (nolock)

--and this later

select * from vw_t1_t2

--end of window3

|||

Yes, NOLOCK table hint will be propageted to the tables in view defination.

It is also very usefull for indexed views as they are treated as tables as well.

Please see following article for more detail.

http://msdn2.microsoft.com/en-us/library/ms190237.aspx

Hope this will answer your question.

Thanks,

FB

|||

I appeciate you taking the time to help me test the theory myself. I didn't think of Opening a transaction and not comitting it to Lock the table..

To answer your question it does propogate down..

|||

THank you for that answer it was very helpful...

No Lock

Lets say i have a view.

vuTestingNoLocks

this view looks like this...

Create View vuTestingNoLocks as

SElect *

From dbo.Employees

inner Join dbo.EmployeeTerritories on EmployeeTerritories.EmployeeID = Employees.EmployeeID

If I select from this view using Select * From vuTestingNoLocks (NOLOCK)

Does the (nolock) command propegate down through the tables? Meaning will it scan tables that are locked still ignoring their locks?

I think you should be able to test it out and come to your own conclusions. Let me know what you are going to interpret from this.

In one window, create these tables, populate dummy data and create the view

Code Snippet

--Start of window1

create table t1 (t1id int identity(10,10),

t1code char(2)

)

create table t2 (t2id int,

t2name varchar(10)

)

insert t1 select 'AB'

insert t1 select 'BC'

insert t1 select 'CD'

insert t2 select 10, 'Group AB'

insert t2 select 20, 'Group BC'

insert t2 select 30, 'Group CD'

create view vw_t1_t2 as

select t1id, t1code, t2name

from t1 join t2

on t1.t1id = t2id

--End of window1

--start of window2

--we are setting up to take exclusive lock

begin tran

update vw_t1_t2

set t1code = 'KK'

--end of window2

--start of window3

--Issue this once

select * from vw_t1_t2 (nolock)

--and this later

select * from vw_t1_t2

--end of window3

|||

Yes, NOLOCK table hint will be propageted to the tables in view defination.

It is also very usefull for indexed views as they are treated as tables as well.

Please see following article for more detail.

http://msdn2.microsoft.com/en-us/library/ms190237.aspx

Hope this will answer your question.

Thanks,

FB

|||

I appeciate you taking the time to help me test the theory myself. I didn't think of Opening a transaction and not comitting it to Lock the table..

To answer your question it does propogate down..

|||

THank you for that answer it was very helpful...

Monday, March 26, 2012

No dbo in the database!

Hi All
I have a database where there is no dbo user. There seems
to be some login mismatch that I can't fix up.
The master shows sa (in fact sa is the dbo in another db
on the same server) but sa, dbo does not appear in one of
the other databases and I can't add it.
I've checked out KB 305711 but it doesn't help.
Thanks
JIn Query Analyzer,
USE the database and issue this command:
EXEC sp_changedbowner 'sa'
--
HTH
--
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com
"J" <anonymous@.discussions.microsoft.com> wrote in message
news:000501c3af13$941724d0$a001280a@.phx.gbl...
> Hi All
> I have a database where there is no dbo user. There seems
> to be some login mismatch that I can't fix up.
> The master shows sa (in fact sa is the dbo in another db
> on the same server) but sa, dbo does not appear in one of
> the other databases and I can't add it.
> I've checked out KB 305711 but it doesn't help.
> Thanks
> J

No dbo for a database - but there are db_owner users

I have a number of user databases who have lost their owner. That is, displaying properties for the database says the owner is unknown.

I assume that any user for such a database that's assigned to the db_owner role can admin everything in this database? Which means that the lack of a dbo doesn't cause any other problem than making it impossible to run a sp_helpdb for the database, or...?

Of course I'd like to make someone the owner, but it seems difficult to make an already existing database user the owner, without dropping the user and re-creating it.Methinks you need sp_changedbowner (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_ca-cz_30s2.asp), which makes the fix trivial anywhere you can execute a stored procedure (such as in Query Analyzer).

-PatP|||Yes, but it doesn't work if the user to be the new owner is already a user in that database. Seems like I need to drop the user and re-create it?|||Yep. Otherwise, SQL Server would have to make a choice about what permissions to grant that user. Especially if that user were dropped from db_owners. The user should see no difference, unless they have created objects under their own username.

Monday, February 20, 2012

Newbie: Index Tuning Wizard

Hi,
I am set (by the sa) as a dbo, "full everything" for my Database.
However when I start the Index Tuning Wizard it complains that I need to be
in the sysadmin group
Also, what is the difference between all these Indexing Wizards? I want for
the server to suggest to me the indexes , for better performance. (Profiler,
etc.- which the other wizards seem not to have. They operate on a table
level.)
TIA
-steve
steve
To run Profiler you have to be a member of sysadmin server role
Usually , we run Profiler , save the data to the file and then examine the
file on Index Tuning Wizard
But there are many options
"steve" <steve@.here.com> wrote in message
news:Idrie.96895$th3.1203245@.wagner.videotron.net. ..
> Hi,
> I am set (by the sa) as a dbo, "full everything" for my Database.
> However when I start the Index Tuning Wizard it complains that I need to
be
> in the sysadmin group
> Also, what is the difference between all these Indexing Wizards? I want
for
> the server to suggest to me the indexes , for better performance.
(Profiler,
> etc.- which the other wizards seem not to have. They operate on a table
> level.)
> TIA
> -steve
>
|||Ok, but this doesn't make much sense!
Does it mean I have to be a sysadmin to use a Wizard to Index my *own* DB
?.
As i said i am a newbie, Is there a way for the administrator to give me the
required permissions, and what are they, without him feeling threatened that
i have acess to other DB's in the server?
I am very perplexed, it doesnt make sense for Microsoft not to allow a dbo
to run a Profiler,Wizard in his own database.
I also think i read somewhere that dbo is enough, but obviously doesn't
apply in my case.
Thanx again!
"Uri Dimant" <urid@.iscar.co.il> a crit dans le message de news:
ec$Ho22WFHA.3864@.TK2MSFTNGP10.phx.gbl...
> steve
> To run Profiler you have to be a member of sysadmin server role
> Usually , we run Profiler , save the data to the file and then examine the
> file on Index Tuning Wizard
> But there are many options
>
>
> "steve" <steve@.here.com> wrote in message
> news:Idrie.96895$th3.1203245@.wagner.videotron.net. ..
> be
> for
> (Profiler,
>

Newbie: Index Tuning Wizard

Hi,
I am set (by the sa) as a dbo, "full everything" for my Database.
However when I start the Index Tuning Wizard it complains that I need to be
in the sysadmin group
Also, what is the difference between all these Indexing Wizards? I want for
the server to suggest to me the indexes , for better performance. (Profiler,
etc.- which the other wizards seem not to have. They operate on a table
level.)
TIA
-stevesteve
To run Profiler you have to be a member of sysadmin server role
Usually , we run Profiler , save the data to the file and then examine the
file on Index Tuning Wizard
But there are many options
"steve" <steve@.here.com> wrote in message
news:Idrie.96895$th3.1203245@.wagner.videotron.net...
> Hi,
> I am set (by the sa) as a dbo, "full everything" for my Database.
> However when I start the Index Tuning Wizard it complains that I need to
be
> in the sysadmin group
> Also, what is the difference between all these Indexing Wizards? I want
for
> the server to suggest to me the indexes , for better performance.
(Profiler,
> etc.- which the other wizards seem not to have. They operate on a table
> level.)
> TIA
> -steve
>|||Ok, but this doesn't make much sense!
Does it mean I have to be a sysadmin to use a Wizard to Index my *own* DB
'.
As i said i am a newbie, Is there a way for the administrator to give me the
required permissions, and what are they, without him feeling threatened that
i have acess to other DB's in the server?
I am very perplexed, it doesnt make sense for Microsoft not to allow a dbo
to run a Profiler,Wizard in his own database.
I also think i read somewhere that dbo is enough, but obviously doesn't
apply in my case.
Thanx again!
"Uri Dimant" <urid@.iscar.co.il> a crit dans le message de news:
ec$Ho22WFHA.3864@.TK2MSFTNGP10.phx.gbl...
> steve
> To run Profiler you have to be a member of sysadmin server role
> Usually , we run Profiler , save the data to the file and then examine the
> file on Index Tuning Wizard
> But there are many options
>
>
> "steve" <steve@.here.com> wrote in message
> news:Idrie.96895$th3.1203245@.wagner.videotron.net...
> be
> for
> (Profiler,
>

Newbie: Index Tuning Wizard

Hi,
I am set (by the sa) as a dbo, "full everything" for my Database.
However when I start the Index Tuning Wizard it complains that I need to be
in the sysadmin group
Also, what is the difference between all these Indexing Wizards? I want for
the server to suggest to me the indexes , for better performance. (Profiler,
etc.- which the other wizards seem not to have. They operate on a table
level.)
TIA
-stevesteve
To run Profiler you have to be a member of sysadmin server role
Usually , we run Profiler , save the data to the file and then examine the
file on Index Tuning Wizard
But there are many options
"steve" <steve@.here.com> wrote in message
news:Idrie.96895$th3.1203245@.wagner.videotron.net...
> Hi,
> I am set (by the sa) as a dbo, "full everything" for my Database.
> However when I start the Index Tuning Wizard it complains that I need to
be
> in the sysadmin group
> Also, what is the difference between all these Indexing Wizards? I want
for
> the server to suggest to me the indexes , for better performance.
(Profiler,
> etc.- which the other wizards seem not to have. They operate on a table
> level.)
> TIA
> -steve
>|||Ok, but this doesn't make much sense!
Does it mean I have to be a sysadmin to use a Wizard to Index my *own* DB
'.
As i said i am a newbie, Is there a way for the administrator to give me the
required permissions, and what are they, without him feeling threatened that
i have acess to other DB's in the server?
I am very perplexed, it doesnt make sense for Microsoft not to allow a dbo
to run a Profiler,Wizard in his own database.
I also think i read somewhere that dbo is enough, but obviously doesn't
apply in my case.
Thanx again!
"Uri Dimant" <urid@.iscar.co.il> a écrit dans le message de news:
ec$Ho22WFHA.3864@.TK2MSFTNGP10.phx.gbl...
> steve
> To run Profiler you have to be a member of sysadmin server role
> Usually , we run Profiler , save the data to the file and then examine the
> file on Index Tuning Wizard
> But there are many options
>
>
> "steve" <steve@.here.com> wrote in message
> news:Idrie.96895$th3.1203245@.wagner.videotron.net...
>> Hi,
>> I am set (by the sa) as a dbo, "full everything" for my Database.
>> However when I start the Index Tuning Wizard it complains that I need to
> be
>> in the sysadmin group
>> Also, what is the difference between all these Indexing Wizards? I want
> for
>> the server to suggest to me the indexes , for better performance.
> (Profiler,
>> etc.- which the other wizards seem not to have. They operate on a table
>> level.)
>> TIA
>> -steve
>>
>