Re: Attach database became readonly

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks roger. Does not work. I give up.

"Roger Wolter[MSFT]" wrote:

Unfortunately, the default of local system doesn't apply to SQL Express.
Try adding

SQLACCOUNT="NT AUTHORITY\LOCAL SERVICE"

to the command line

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Locus" <Locus@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F9C85C4E-9FAA-4691-98FB-01B2757779EF@xxxxxxxxxxxxxxxx
Thanks Roger. It is exactly what I run to. When I changed the default user
to
Local System. The attachment behalf as per normal.

Now, my problem becomes how to install it so that it is set to Local
System.

I read the articles at
http://msdn2.microsoft.com/en-US/library/ms144259.aspx#sqlaccount1,
"[SQLACCOUNT], [SQLPASSWORD], [AGTACCOUNT], [AGTPASSWORD], [ASACCOUNT],
[ASPASSWORD], [RSACCOUNT], and [RSPASSWORD]
This is information for the Service Accounts dialog box. If these
parameters
are not specified, Setup defaults to the LocalSystem account."

I specified none of these parameters, it still default to "NT
Systems/Network Services".

My installation string is as follow:
start /wait sqlexpr32.exe /qb SQLBROWSEAUTOSTART=0 SQLAUTOSTART=1
SQLCOLLATION="SQL_Latin1_General_Cp1_CS_AS" DISABLENETWORKPROTOCOLS=0
ERRORREPORTING=1 INSTANCENAME="YYY" INSTALLSQLDATADIR="C:\\Program
Files\\Microsoft SQL Server\\" INSTALLSQLDIR="C:\\Program Files\\"
INSTALLSQLSHAREDDIR="C:\\Program Files\\" SECURITYMODE=SQL
SAPWD="Passw0rd!"
ADDLOCAL="ALL"

Anyway I can set the installaytion string so that default user is Local
System?


"Roger Wolter[MSFT]" wrote:

The read-only behavior didn't change between SQL Server 200 and SQL
Server
2005 but the default user that the service runs as changed from Local
System
to Network Service so the user that requires the permissions changed. I
assume this is what you are running into

--
This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Locus" <Locus@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:00D7397A-516B-4BA0-ADE4-991CA8A546CA@xxxxxxxxxxxxxxxx
Thanks Roger.

I found out that the directory is readonly, but .mdf and .ldf files are
not
readonly (i.e. read and write). I change the directory to not readonly,
the
attached database behave as normal (i.e. it on longer is readonly
database).

I used MSDE and SQL2000, the same does not apply to them even though
the
directory is readonly. i.e. when the files are read write and the
directory
they are residing is readonly, attaching the database will have a
normal
database (not a readonly database).

I install my application on user machine using Visual Studio setup
project,
the program copy the files to the machine decided by user (by default
it
goes
to c:\program files\MyProgram\...). Apparently during this setup, the
directory is created as readonly.

I think there are 2 ways around the problem.
1. Setup project set the directory created as a non-readonly directory.
I
look everywhere in VS setup project, I can set the directory to
non-readonly.
Is there a way to set it to non-readonly?

2. Make SQL 2005 Express attach database behaves like MSDE or SQL 2000,
i.e.
when .mdf and .ldf files are non-readonly, it attaches as normal
database.
(Instead of depending on directory they are resided in). Is there such
a
way
to get around in SQL2005 Express?

- Locus

"Roger Wolter[MSFT]" wrote:

Right click on the file in explorer and go into the security setup.
The
easiest thing to do to see if it works is to make everybody read
write.

--
This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Locus" <Locus@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:BD76D6C6-CE32-426E-BB4E-608E4A78B269@xxxxxxxxxxxxxxxx
Hi Roger,

The user that start the service is "NT Authroity/Network Service".
Where
can
I change the windows permission as you have suggested to make the
file
not
readonly?

Thanks
--Locus

"Roger Wolter[MSFT]" wrote:

It's probably read only because the user that the SQL Server
service
runs
as
only has read permissions on the files. Change the Windows
permissions
and
restart the database service.

--
This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of included script samples are subject to the terms specified
at
http://www.microsoft.com/info/cpyright.htm

"Locus" <Locus@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:02FD1A89-D056-4585-8D7E-6B38BA17570F@xxxxxxxxxxxxxxxx
I created a database "mydatabase".

I detach it.

Then I copy "mydatabase.mdf" and "mydatabase_log.ldf" to
c:\myprojectdirectory.

Then, I attach it using:
exec sp_attach_db 'mydatabase', 'mydatabase.mdf',
'mydatabase_log.ldf'

The command succesfully executed but the database is readonly.

What should I do so that after attaching it is not a readonly
database?

-Locus












.



Relevant Pages

  • Re: Using ldifde & csvde
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... > How can I get the Windows 2000 versions and will they work with a Windows ... >> Use of included script samples are subject to the terms specified at ...
    (microsoft.public.windows.server.active_directory)
  • RE: SQLSink Sample
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... Use of included script samples are subject to the terms specified at ...
    (microsoft.public.vsnet.enterprise.tools)
  • Re: Convert Express To Server
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... Use of included script samples are subject to the terms specified at ...
    (microsoft.public.sqlserver.setup)
  • Re: Programmatically replicate an Active Directory partition
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... > Use of included script samples are subject to the terms specified at ...
    (microsoft.public.windows.server.active_directory)
  • Re: Lost admin access to ADAM
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... Use of included script samples are subject to the terms specified at ...
    (microsoft.public.windows.server.active_directory)