Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm working with a tool that as one of the automated steps will attach databases from my file system to my local SQL Express 2008 instance. The tool requires a login in the sysadmin server role, for which I've created a new dummy login for testing. When I log into Management Studio with this new login and run the exact query to attach the DBs, the DBs are attached fine. However, when I run the tool (its an executable program) I am able to turn on the tool's debug panel to see the following error:

CREATE DATABASE Permission denied in database 'master'

The T-SQL being executed via the program is:

USE [master]
GO
CREATE DATABASE [BBB_core] ON
( FILENAME = N'c:\inetpub\wwwroot\BBB\Databases\sitecore.core.Mdf' ),
( FILENAME = N'c:\inetpub\wwwroot\BBB\Databases\sitecore.core.Ldf' )
FOR ATTACH
GO

USE [master]
GO
CREATE DATABASE [BBB_master] ON
( FILENAME = N'c:\inetpub\wwwroot\BBB\Databases\sitecore.master.Mdf' ),
( FILENAME = N'c:\inetpub\wwwroot\BBB\Databases\sitecore.master.Ldf' )
FOR ATTACH
GO

USE [master]
GO
CREATE DATABASE [BBB_web] ON
( FILENAME = N'c:\inetpub\wwwroot\BBB\Databases\sitecore.web.Mdf' ),
( FILENAME = N'c:\inetpub\wwwroot\BBB\Databases\sitecore.web.Ldf' )
FOR ATTACH
GO

My thought here is that my Windows user somehow cannot execute this query on the master database. I do have my local Windows user (a domain user) in the logins on my SQL instance and its a member of sysadmins. I've also tried running the program as administrator (right-click > Run as administrator). I know the query works, it just doesn't seem to work in the context of the program. Am I missing something?

I'm using SQL Express 2008 on Windows 7 x64

Thanks in advance for any help.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If you can run the code you posted successfully in the context of your domain account then it's likely the tool is connecting to your database as a different user. Are you able to inspect the connection string it uses? If so, check to see if it's using Integrated Authentication or is using a User ID/Password combination and modifying things accordingly there. Either change the connection string to use Integrated Authentication or the SQL login that you created as a test.

share|improve this answer
    
Somehow your comment triggered me to delete my domain login and re-create it. Once I recreated it and added it to sysadmin, it works now. Weiiirrrddd... thanks! –  Mark Ursino Jan 30 '12 at 17:34
    
Hmm, that is weird. I could see where you'd have a mismatch if you'd restored a database to your local instance from another instance but not sure how it'd get out of sync at the instance level. Glad it's working now. –  squillman Jan 30 '12 at 17:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.