CREATE DATABASE Permission denied in database 'master' error 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.
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.