MSDN > Home page del forum > Visual Studio Database Development Tools (Formerly "Database Edition Forum") > Role membership is managed in the transacted part of the script
Formula una domandaFormula una domanda
 

Con rispostaRole membership is managed in the transacted part of the script

  • venerdì 15 maggio 2009 16.00TheBeardedLlama Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    Hello (again),

    Sick of me yet? ;P

    So, now it's time to start getting my other team mates to start using the database project.

    I just had a very interesting thing happen. The short story is that when the "Include transactional scripts" deployment setting is enabled and "Ignore role membership" is disabled, then GDR sticks the EXECUTE sp_addrolemember @rolename = N'xxx', @membername = N'yyy' statements in the transaction part of the script even though this cannot be done inside a transaction (as management studio says if you try to run the generated deployment script).

    Another bug?

    Cheers,
    Steven

Risposte

  • giovedì 21 maggio 2009 21.06tomsmiMSFTMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta
    Did some more investigating - are you by chance deploying to a SQL 2000 server?   Because a SQL 2000 server does get that error. 

    Thanks,
    -Tom

    Tom Smith, SDET - Microsoft Visual Studio Team Edition for Database Professionals
  • venerdì 22 maggio 2009 8.17TheBeardedLlama Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta
    Hello Tom,
    No I wasn't, but I have a strong suspicion that it had to do with the compatibility level and your comments have confirmed this.
    Sorry about the false alarm, but just in case anybody else gets stuck:
    Make sure that when you generate a script for SQL Server 2005 you are not deploying to SQL Server 2005 with the compatibility level set to SQL Server 2000.

    Cheers,
    Steven

Tutte le risposte

  • lunedì 18 maggio 2009 20.36tomsmiMSFTMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    Hi Steven,

    Based on my findings, it appears as though SQL server does allow role sp_addrolemember statements to be executed inside of a transaction.  What is the error you are getting when you try to deploy your script?  The error should be able to help me investigate further.

    Thanks!

    -Tom

    Tom Smith, SDET - Microsoft Visual Studio Team Edition for Database Professionals
  • martedì 19 maggio 2009 8.36TheBeardedLlama Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    Hello Tom,

    The script was run on SQL Server 2005 Developer edition. The error said that the sproc to add a role member cannot be run inside a transaction.
    I just had a thought: would the compatibility level affect this behaviour?

    Cheers,
    Steven
  • mercoledì 20 maggio 2009 0.53tomsmiMSFTMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    Hmmm...What compat level is your database?   Can you by chance send the sample deploy script that is failing?  Maybe I'm misisng something and don't have a deploy setting that matches yours?

    Thanks!
    -Tom

    Tom Smith, SDET - Microsoft Visual Studio Team Edition for Database Professionals
  • giovedì 21 maggio 2009 21.06tomsmiMSFTMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta
    Did some more investigating - are you by chance deploying to a SQL 2000 server?   Because a SQL 2000 server does get that error. 

    Thanks,
    -Tom

    Tom Smith, SDET - Microsoft Visual Studio Team Edition for Database Professionals
  • venerdì 22 maggio 2009 8.17TheBeardedLlama Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta
    Hello Tom,
    No I wasn't, but I have a strong suspicion that it had to do with the compatibility level and your comments have confirmed this.
    Sorry about the false alarm, but just in case anybody else gets stuck:
    Make sure that when you generate a script for SQL Server 2005 you are not deploying to SQL Server 2005 with the compatibility level set to SQL Server 2000.

    Cheers,
    Steven
  • mercoledì 1 luglio 2009 5.24snoopdiggy Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    Although this may be true for sp_addrolemember, it is NOT true for sp_droprolemember

    VSTS Database GDR will try to execute sp_droprolemember within the transaction and an error message is produced:

    "The procedure 'sys.sp_droprolemember' cannot be executed within a transaction."