Showing posts with label role. Show all posts
Showing posts with label role. Show all posts

Friday, February 24, 2012

Creating Log file & Attaching db?

Bit of a SQL newbie, having taken over a support role for a piece of software that my firm sells. It is basically a DB that runs on MSDE or SQL Server in either desktop or enterprise scenarios.

We do sell our software to clients who may or may not already have SQL on their machines. During installation, it searches for sqlservr.exe for existing SQL installations and if it finds nothing, will then install MSDE 1.0 to house the db files.

My question is this -

I can manually create a db or manually attach an existing db through sql query analyser where there is a full-blown SQL installation. Is there any way I can do the same where there is only MSDE installed? The simple solution, I guess, would be to download one of the freeware or shareware MSDE "Enterprise Managers", but this won't always be suitable for a client installation.

Many thanks for your assistance all.

:cool:you could use sp_attach_db to attach a sqlserver database to sqlserver. Don't know about msde though.|||you could use sp_attach_db to attach a sqlserver database to sqlserver. Don't know about msde though.

Thanks

Yep, this is what I would use if I was doing it through the SQL. Still wondering about MSDE tho.
:confused:|||You can look into SQL-DMO and write up a quick routine that would do the attaching.

Tuesday, February 14, 2012

Creating databases under MS SQL 2005 Server (SP-2): dbo user role

Good Day,

I am having a problem with creating databases in MS SQL 2005 Server. When I attempt to assign an User Mapping for my SQL user account to the newly created database, the "dbo" user and schema is already assigned. When I try to drop this user in favor of my own, I receive an error message: Cannot alter the user "dbo" (Microsoft SQL Server, Error: 15150). I am connected to my database engine through the "sa" account.

Regards,

Keith

Hi Keith,

The login that creates the database is mapped to a special user called dbo. The dbo is the owner of the database and can not be dropped. The dbo schema is associated with the dbo user so it also can not be dropped.

The sa account will represent itself as dbo in all databases.

to check for yourself: select user_name() when logged in as sa.

Hope this helps,

-Steven Gott

SDE/T

SQL Server

|||

I have a database that must have a unique schema and user account assigned. I want to exchange the default "dbo" user with my own.

Regards,

Keith

|||

Create a new schema and assign the schema owner as whatever user you want to use:

CREATE SCHEMA YourSchemaName AUTHORIZATION YourUserName

If there are already objects in the dbo schema that you need to be in YourSchema, you change the schema with:

ALTER SCHEMA YourSchemaName TRANSFER dbo.ObjectNameToTransfer

You can then assign users the default schema of YourSchemaName. You can change the default schema for exsiting users with:

ALTER USER YourUserName WITH DEFAULT_SCHEMA = YourSchemaName

-Sue

|||

Here is the error that I receive when trying to create a new schema for my database:

Msg 15151, Level 16, State 1, Line 1
Cannot find the user 'cqadmin', because it does not exist or you do not have permission.
Msg 2759, Level 16, State 0, Line 1
CREATE SCHEMA failed due to previous errors.

My user, "cqadmin" has public access of the database in question.