Random Select mailbox database

Hello,

Can someone tell me a better way to select random mailbox database?

We have our mailbox databases named to start with the location of the user.

Location may by AU, US, or UK.

Example:

  • US-MAILBOX-DB1
    US-MAILBOX-DB2
    US-MAILBOX-DB3
    US-MAILBOX-DB4
  • AU-MAILBOX-DB1
    AU-MAILBOX-DB2
    AU-MAILBOX-DB3
    AU-MAILBOX-DB4
  • UK-MAILBOX-DB1
    UK-MAILBOX-DB2
    UK-MAILBOX-DB3
    UK-MAILBOX-DB4

I put in a script that should do the random selection based on the DB name.

Public Function CCC_MailboxDBSelect( _
Optional ByVal location As String = Nothing) As String

Dim DB As String = Nothing

DB = Connection.GetSingleProperty("EX0MailBoxDatabase", "NAME", "NAME = (Select TOP 1 name from EX0MailBoxDatabase where name Like '" & location & "-%' ORDER BY newid())").ToString

Return DB
End Function

When I do a SQL select it always works with-out and issues and selects a random DB server based on the name starting with the location.

When I run the script with my test it does not keep the select based on the name it just selects a random DB server.

select TOP 1 NAME from EX0MailboxDatabase
Where name like 'US-%'
ORDER BY newid()

Can anyone tell me if the Connection.GetSingleProperty function can do the query? Maybe another function or way someone can suggest?

Lu

Parents Reply Children