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

Tuesday, March 27, 2012

Cannot remove dbo rights from a user

In the login properties on the Database Access tab, a user's name says
dbo instead of his name. I do not want him to have dbo permissions. I
cannot drop the db_owner permissions that he has on the database
because I get the error "Error 15405: Cannot use the reserved user or
role name 'dbo'."

How do I remove these permissions from this user?MK (mhedblom@.libertysite.com) writes:
> In the login properties on the Database Access tab, a user's name says
> dbo instead of his name. I do not want him to have dbo permissions. I
> cannot drop the db_owner permissions that he has on the database
> because I get the error "Error 15405: Cannot use the reserved user or
> role name 'dbo'."
> How do I remove these permissions from this user?

Obviously this person is the owner of the database. If you don't want
this, use sp_changedbowner to make someone else the DB owner.

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

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Unfortunately it was not that obvious. The properties of the database
did NOT have him as the owner. It showed the owner as our system
account. However, I ran sp_changedbowner anyway just as a test and it
removed his alias'. Strange but thank you so much!

Erland Sommarskog wrote:
> MK (mhedblom@.libertysite.com) writes:
> > In the login properties on the Database Access tab, a user's name says
> > dbo instead of his name. I do not want him to have dbo permissions. I
> > cannot drop the db_owner permissions that he has on the database
> > because I get the error "Error 15405: Cannot use the reserved user or
> > role name 'dbo'."
> > How do I remove these permissions from this user?
> Obviously this person is the owner of the database. If you don't want
> this, use sp_changedbowner to make someone else the DB owner.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx|||MK (mhedblom@.libertysite.com) writes:
> Unfortunately it was not that obvious. The properties of the database
> did NOT have him as the owner. It showed the owner as our system
> account. However, I ran sp_changedbowner anyway just as a test and it
> removed his alias'. Strange but thank you so much!

Have the database been restored/attached from a different server
instance?

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

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspxsql

Friday, February 24, 2012

Cannot insert the value NULL into column 'ID'

Hi dear experts:

The message is

"Cannot insert the value NULL into column 'ID_Month', table 'Database_DW.dbo.Incident_Summary'; column does not allow nulls..."

At my table, I have a primary key which make autonumber for any record set in column 'ID_Month'. How can I insert autonumber in column 'ID_Month'by SQL statement?

Thank you in advance.

It's possible you are explictly inserting null into the column rather than ignoring it. Check all column mappings and sql statements to ensure you are not referencing that column. For example:

insert Database_DW.dbo.Incident_Summary(ID_Month, column1) select(NULL,somevalue) from sometable; would return that error.

|||

Hi Michanne,

thank you for the quick respond. Yes, you are wright, I am inserting nulls in the column that does not allow nulls.

My question is how to insert next number in the column by sql statement. I copied the d/base with data, 57 records exists in it and I don't know how to insert the record that will be number 58.

Thanks.

|||

Leave it empty in your statement. Don't reference in your column list either. It will insert it automatically as long as 58 is the next identity value. (SELECT IDENT_SEED('table') will tell you this.) I think that is what you are getting at....

There are also functions that allow you to override the identity key value but you only need to do that if you care about the value or have to correct the value in the table. To do that look up the syntax for "Set Identity insert" in BOL.

Hope that helps!

|||

Thanks for following michanne!

I can't leave it. In this case I receive a message "Cannot insert the value NULL into column 'ID_Month'. It is something with identity syntax. I can't figure out.

Thank you!

|||

Check the schema. If it is >truly< an identity it will work to insert all other columns and ignore the one that is an identity.

|||

Once again, thank you!! Checked the schema, no identity, it is float with no null values.

Your suggestion was so helpful!!

Sunday, February 12, 2012

Cannot find either column "dbo" or the user-defined function

Hi,

I have a stored procedure that calls a scalar function. It works fine on my development database, but on my production database, I get this error when trying to execute the procedure:

Cannot find either column "dbo" or the user-defined function or aggregate "dbo.MyFunction", or the name is ambiguous.

However, I am able to execute the function outside of the procedure like this: select dbo.MyFunction(0, 0)

Anyone have idea? I can't figure it out.

Make sure that you have deployed the function ins the right DataBase from which you want to access...Some time this happens that the function will be deployed to a different DataBase or to the master DB by mistake.Also make sure that you grant the exeute permission on function to the user with which you currently trying to execute

|||

Thanks for the reply. It's definitely in the right database, I see it when I run

SELECT * FROM INFORMATION_SCHEMA.Routines

I'm pretty sure the permissions are OK, I am able to execute the function in a SQL query, but it's not working when I execute a stored procedure that uses it.

Any other ideas?

|||

Can u post the code you've written in the sproc and function?

|||

Yes, here it is:

set ANSI_NULLSONset QUOTED_IDENTIFIERONgoCREATE FUNCTION [dbo].[DistanceBetweenTEST]()RETURNSfloatASBEGIN-- test codereturn 10.2345ENDCREATE PROCEDURE [dbo].[md_UserSearchTEST]ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;-- test codeSELECT1WHERE dbo.md_DistanceBetweenTEST() > 5END-- this returns a value as expectedselect dbo.DistanceBetweenTEST()-- this throws an exceptionexec md_UserSearchTEST/*Msg 4121, Level 16, State 1, Procedure md_UserSearchTEST, Line 10Cannot find either column "dbo" or the user-defined function or aggregate "dbo.md_DistanceBetweenTEST", or the name is ambiguous.*/
|||

What exactly are you trying to do? Your function name is DistanceBetweenTEST, but you are calling it withmd_DistanceBetweenTEST? You got it all messed up. Explain what you are trying to do so we can help.

|||

WOW. I don't know why I didn't see that. That was the problem right there.

I think I've been looking at this for too long. Thanks.