3

In one of my test I need to create a SQL Express database and then populate it.

It's run fine on my machine but when TeamCity tries to run the very same test it throws the following exception:

Test(s) failed. System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.Data.SqlClient.SqlException : CREATE DATABASE permission denied in database 'master'.

What could be causing this?

Ben
  • 1,196
  • 2
  • 11
  • 25
  • 1
    [Check this](http://blogs.msdn.com/b/dparys/archive/2009/09/17/create-database-permission-denied-in-database-master-my-fix.aspx) or [This](http://stackoverflow.com/questions/1616515/sql-server-express-create-database-permission-denied-in-database-master) – noobob May 09 '13 at 11:57
  • 1
    what account is your teamcity agent running under? Does it run as a user that has permission? – James Woolfenden May 10 '13 at 09:50
  • I use this [script](http://archive.msdn.microsoft.com/addselftosqlsysadmin/) to solve the problem – Ben May 10 '13 at 15:08
  • @james [.]\System account – Ben May 10 '13 at 15:13

2 Answers2

1

In Enterprise Manager-> Data Basericht click on master db select Properties and add your permission

KF2
  • 9,887
  • 8
  • 44
  • 77
1

I use this script to give administrator permission to [.]\System user (which is team city agent account).

Ben
  • 1,196
  • 2
  • 11
  • 25