Run below query on "new query window" and get the service account name.
declare @sqlser varchar(20)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key='SYSTEM\CurrentControlSet\Services\MSSQLSERVER',
@value_name='objectname', @value=@sqlser OUTPUT
PRINT 'Account Starting SQL Server Service:' +convert(varchar(30),@sqlser)
After getting the service-account (S/A) try the below steps to provide full privilege to files.
Step 1: Right click on the folder "" where the mdf and ldf files located and click on properties.
Step 2: Click on security tab.
Step 3: Click on Add button and add sql service account (S/A).
Step 4: Provide "Full control" privilege and click ok.
Step 5: Verify both mdf and ldf have modify privilege.
Step 6: Attach the db!
source
Goto RUN
Type services.msc & press enter
In service control manager find the below service w.r.t to your edition.
For SQL Server 2000
MSSQLSERVER
-- for default instance
MSSQL$instancename
-- for named instance
For SQL Server 2005 & SQL Server 2008
SQL Server (MSSQLSERVER)
-- for default instance
SQL Server (instancename)
-- for named instance
Check the "Log On as" for the SQL service and provide modify privilege to that ID in the folder.