Error modifying image during creation -

OrionUKOrionUK Posts: 21 New member
I am running a modification script during an image creation however the script needs to drop tables in the database. When the image creation process gets to the end it generates this error:

An exception was thrown while executing a script: System.Data.SqlClient.SqlError: Cannot drop the table '<tablename>', because it does not exist or you do not have permission.  

Both the SQL Clone and SQL Clone Agent account has the role sysadmin so not sure what permission is needed. 

Thanks.
Tagged:

Best Answer

  • Mark RMark R Posts: 43 Silver 1
    Accepted Answer
    Ah - if you're trying to remove all the users, you'll need to exclude the SQL Clone temporary user. That user will be removed by SQL Clone at the end of the script, and won't be present in the image, so you don't need to remove it yourself. The script can't remove that user because the script is running as that user, and you can't remove the user you're running as.
    Software developer
    Redgate Software

Answers

  • What's the result of the script when it's run from SSMS?

    Are you able to share the script?
    Software developer
    Redgate Software
  • OrionUKOrionUK Posts: 21 New member
    edited September 10, 2018 2:33PM
    The script is supposed to delete all the users so the image created has no permissions. The script runs fine in SSMS because it uses my account. But SQL Clone is creating what I assume is a temporary account called SqlClone_LowPriv_1l5. So when the script runs it fails because it cannot remove SqlClone_LowPriv_1l5. 

    This is what appears in the log:

    The server principal "SqlClone_LowPriv_1l5" is not able to access the database "SqlCloneTemp_4hojwsno" under the current security context.

    My aim is to run a modification script to remove permissions and various table backups on the production database. Then I have a nice clean image of the database to then clone. 

    Thanks.


  • OrionUKOrionUK Posts: 21 New member
    Thanks Mark R. I had to amend my TSQL to include this line:

    AND LEFT(name, 8) <> 'SqlClone'

    So it excludes the temp user. 

    Cheers.

    Still learning about SQL Clone....
Sign In or Register to comment.