A number of the Citrix products (XenDesktop, Provisioning Server, etc.) are capable of utilizing a SQLExpress database to allow for a simple installation experience. Unfortunately, if your install gets whacked or you want to start over there isn’t a simple, GUI way to delete the SQLExpress database in order to start over. Many people end up either installing, or using existing installs, of the full SQL toolstack to accomplish the task. Or they end up scrappping what they’ve done and start over. This post describes the process of deleting the database using the CLI tools that are installed with SQLExpress itself. I will discuss the specifics for XenDesktop 5, but the process is similar for other products.

I must preface this to say that I have not done rigorous testing to determine if there are detrimental side-effects to the following process. I’ve used it a number of times and have not experienced abnormalities. But, as always, this is not endorsed by Citrix and your mileage may vary.

Use at your own risk!

  • Close Desktop Studio.
  • Stop Services
    • Citrix AD Identity Service
    • Citrix Broker Service
    • Citrix Configuration Service
    • Citrix Diagnostic Facility COM server
    • Citrix Host Service
    • Citrix Machine Creation Service
    • Citrix Machine Identity Service
  • Click the Start menu, type “cmd<enter>”

Note: Different versions of SQLExpress store the sqlcmd command in different directories. It’s easiest to use Windows Explorer to search C:\Program Files\Microsoft SQL Server for the correct location.

  • Change to the binary directory where sqlcmd resides:

    cd \Program Files\Microsoft SQL Server\100\Tools\Binn<enter>
  • Connect to the local SQLExpress database instance:

    sqlcmd -S localhost\SQLEXPRESS<enter>
  • List the databases to determine the name of the database to drop:

    sp_databases<enter>

    go<enter>
  • Drop the database

    drop database CitrixXenDesktopDB<enter>

    go<enter>
  • List the databases again to validate it is no longer there:

    sp_databases<enter>

    go<enter>
  • Exit sqlcmd:

    exit<enter>
  • Start Services
    • Citrix AD Identity Service
    • Citrix Broker Service
    • Citrix Configuration Service
    • Citrix Diagnostic Facility COM server
    • Citrix Host Service
    • Citrix Machine Creation Service
    • Citrix Machine Identity Service

When the services spin up the have a rude awakening because the database that existed when they shut down no longer exists. We now have to tell XD5 to start over.

  • Open Desktop Studio
  • On the “Specify the address of a Controller in the site you wish to administer” window select “This machine” and click OK
  • Click Yes when prompted with, “The services are no longer permitted to access the configured database. Would you like to reset the services and retry?”
  • Click “Desktop deployment” on the main Desktop Studio screen
  • Complete the wizard as usual, with the exception of selecting “Use existing database” for the “Database configuration” element and leaving the default values.
  • Click OK to automatically create the database