Convert Meta database name to main site domain

0

Please login or register to vote for this query.

(click on this box to dismiss)

Poker Meta

Q&A about the site for serious players and enthusiasts of poker

SELECT name,
  LOWER(
    CASE
      WHEN name = 'StackExchange.MathOverflow.Meta' THEN 'mathoverflow.net'
      WHEN name = 'StackExchange.Ubuntu.Meta' THEN 'askubuntu.com'
      WHEN PATINDEX('StackOverflow.%.Meta', name) > 0
        THEN SUBSTRING(name, 15, LEN(name) - 19) + '.stackoverflow.com'
      WHEN PATINDEX('StackExchange.%.Meta', name) > 0
        THEN CASE SUBSTRING(name, 15, LEN(name) - 19)
          WHEN 'Audio' THEN 'video'
          WHEN 'Beer' THEN 'alcohol'
          WHEN 'CogSci' THEN 'psychology'
          WHEN 'Garage' THEN 'mechanics'
          WHEN 'Moderators' THEN 'communitybuilding'
          WHEN 'Photography' THEN 'photo'
          WHEN 'Programmers' THEN 'softwareengineering'
          WHEN 'Vegetarian' THEN 'vegetarianism'
          WHEN 'Writers' THEN 'writing'
          ELSE SUBSTRING(name, 15, LEN(name) - 19)
        END + '.stackexchange.com'
      ELSE SUBSTRING(name, 0, LEN(name) - 4) + '.com'
    END)
  FROM sys.databases
  WHERE database_id > 5
    AND name LIKE '%.Meta'

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results