title: Scripting User & Login Creation in SQL Azure
body: <p>I have a bunch of user accounts and server accounts which I need to create on SQL Azure (and then in 4 other environments for (dev,qa,uat &amp; pre-production) and I'm running into some problems.</p>
  
  <p>Problem 1. CREATE LOGIN must be done on master / CREATE USER must be done in the database. but since you can't switch databases with a <code>Use</code> statement, at the very least I'm going to need to do this in 2 batches.</p>
  
  <p>Problem 2. You don't seem to be able to execute the CREATE LOGIN/CREATE USER code in either dynamic sql or as part of an <code>IF</code> block so I can't do an IF NOT EXISTS check around each create statement. </p>
  
  <p>Am I snookered here, or are there any other easy/robust ways to script the creation of SQL Logins &amp; DB Users with some basic existance checking in SQL Azure ?</p>