SQL Server / Renaming Databases With Active Connections

hello-my-name-isI believe there are many methods and opinions that exist on the best practice to rename a SQL Server DB. Below I’ll quickly give you the method I use to rename a database. In the below example, I rename two DB’s – a common scenario if you’re swapping your production database with a different version:

-- #1 change first db name
use master
-- set db to single user
ALTER DATABASE myProdDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE 
-- do the rename
ALTER DATABASE myProdDB MODIFY NAME = [myOldProdDB]
-- set back to multi user
ALTER DATABASE myOldProdDB SET MULTI_USER

-- #2 change second db name
use master
-- set db to single user
ALTER DATABASE myNewProdDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE 
-- do the rename
ALTER DATABASE myNewProdDB MODIFY NAME = [myProdDB]
-- set back to multi user
ALTER DATABASE myProdDB SET MULTI_USER

Note: this does not change the database or log file names, just the database name.

SQL Server / Renaming Databases With Active Connections

Installing & starting with PhoneGap on Windows for cross platform mobile development

Build-BotPhoneGap is a great framework for creating cross platform apps (Android, iOS, BB, WM, etc.) using HTML, CSS, and JavaScript and uses Apache Cordova™. Installing and testing on Windows takes little setup, below I’ve tried to cover all of the steps needed to get going. My setup / guide below uses Windows 7, 64 bit, it seems like many steps, but in reality is pretty easy.

  1. Install node.js from nodejs.org (use default settings).
  2. Open a command prompt (cmd) and run:
    1. npm install -g phonegap
    2. npm install -g ant
    3. npm install –g cordova
    4. Now add ‘C:\Users\<yourusername>\AppData\Roaming\npm\node_modules\ant\ant\bin’ to the Path system variable
    5. Download and extract the Android SDK from https://developer.android.com/sdk/index.html
      1. I extracted to c:\mobile\androidsdk (referenced below as <yoursdkpath>)
      2. Add <yoursdkpath> + \sdk\platform-tools to the Path system variable
      3. Add <yoursdkpath> + \sdk\tools to the Path system variable
      4. Now to setup an Android image to emulate and test with:
        1. In the sdk folder, run Eclipse (ie: C:\mobile\androidsdk\eclipse\eclipse.exe
        2. Create or use the default workspace
        3. In Eclipse, under Window choose Android SDK Manager
        4. In the SDK Manager, make sure these are checked:
        5. i.      Tools > SDK Tools, Platform-tools
        6. ii.      Android <you choose the version> SDK Platform, Arm system image & Intel system image (if available)
        7. iii.      Extras > Android Support Library, Google USB Driver, Intel x86 emulator HAXM
  3. Click Install x Packages, accept all licenses
  4. When downloads are finished, close the SDK Manager
  5. If you want to speed up the Android emulator, I suggest installing the Intel HAXM located at: \sdk\extras\intel\Hardware_Accelerated_Execution_Manager
  6. Now back in Eclipse (restart if you’ve installed the HAXM), you can go to Window > Android Virtual Device Manager.
  7. Click “New” to create a new virtual device
  8. Choose a name (anything you want)
  9. Choose a device (something simple like the “4.0” WVGA”)
  10. Choose a target (this is what you downloaded in step 4d).
  11. In CPU, choose Intel if it’s available (it’s not required, but if it’s not available, double check the HAXM install and the download the Intel system image for your target version)
  12. Now you can click “OK”
  13. In the list of virtual devices, choose your new device and click “Start”
  14. Provided you don’t see any errors, after a few minutes (be patient) you’ll have a working Android emulator going. android-emulator
  15. Now, let’s do a quick project and test it! Go back to cmd (your command prompt).
  16. Create your project with, run: cordova create hello com.ex.hello “HelloChris”
  17. Go to the project directory, run: cd hello
  18. Add android to the project, run: cordova platform add android
  19. To make sure your project is ok, run: cordova build
  20. Now if you don’t already have your emulator running, go back into Eclipse into the Android Virtual Device Manager and start your device.
  21. When it’s running, run: cordova emulate android
  22. That’s it; you should see “your” app on the emulator in a few seconds. (It reads “device ready” with a logo or something…).

Continue reading “Installing & starting with PhoneGap on Windows for cross platform mobile development”

Installing & starting with PhoneGap on Windows for cross platform mobile development