title: Determine Security Differences Between Two SQL Servers Database Users
body: <p>We're running SQL Server 2012 / .Net Framework 4.5.1</p>
  
  <p>We have an application that does the following:</p>
  
  <ol>
  <li>Extract all table data from a source database using an instance of .Net's <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx" rel="nofollow">SqlBulkCopy</a>.</li>
  <li>Delete all data in a target database using regular SQL statements.</li>
  <li>Deploy the data from the source database to the target database using an instance of .Net's SqlBulkCopy.</li>
  </ol>
  
  <p>The third step is successful when the SQL connection uses my Active Directory account, but fails with the following error message when using a SQL Server account created for this purpose:  <em>Cannot find the object "[SchemaName].[TableName]" because it does not exist or you do not have permissions.</em></p>
  
  <p>Interestingly, the process runs through about a dozen tables before hitting one that causes this error.  Manual verification proves that a) The table exists on the target, b) The problem user can select from the table, and c) the problem user can manually insert into the table with the standard INSERT INTO [SchemaName].[TableName] ([Columns]) VALUES ([Values]) format.  BCP also works for that user, but using SqlBulkCopy from a .Net application fails for the same user.</p>
  
  <p>Our DBA (A pretty seasoned guy, so far as I can tell, actually) says that the database permissions on the target database are IDENTICAL between the two users, but reality would seem to suggest this is not the case.</p>
  
  <p>Googling the problem shows that the user should have the db_owner or db_ddladmin roles.  The user actually belongs to both.</p>
  
  <p>Anyway, solving the local problem is of secondary concern, since I can get done what I need done with my AD account.  <strong>What I'd really like to know is whether there is a baked-in way to compare the differences in permissions between two users.  If not, can this be done with a T-SQL query of some kind?</strong></p>
  
  <p>Thanks, guys and gals!</p>