Dupes and relates of your posts, network-wide

1

Please login or register to vote for this query.

(click on this box to dismiss)

Chess

Q&A for serious players and enthusiasts of chess

DECLARE @output TABLE (
  DbName VARCHAR(MAX),
  UserName VARCHAR(MAX),
  AccountId INT,
  Reputation INT,
  PostId INT,
  PostType VARCHAR(MAX),
  DupeTitle VARCHAR(MAX),
  YourTitle VARCHAR(MAX),
  DupeCreationDate DATETIME,
  YourCreationDate DATETIME,
  ClosedDate DATETIME,
  DupeScore INT,
  YourScore INT
);

DECLARE @query VARCHAR(MAX);

DECLARE dbcursor CURSOR FOR
SELECT name
FROM sysdatabases
WHERE name NOT IN ('master', 'tempdb', 'model' ,'msdb', 'Data.StackExchange');

DECLARE @DbName VARCHAR(MAX);

OPEN dbcursor;
FETCH NEXT FROM dbcursor INTO @dbname;

WHILE @@FETCH_STATUS = 0
BEGIN
  /*
  SELECT @query = '
    SELECT
      ''' + @DbName + ''' AS DbName,
      Users.DisplayName AS UserName,
      Users.AccountId AS AccountId,
      Posts.Id AS PostId,
      Posts.CreationDate AS PostCreationDate
    FROM [' + @dbname + '].dbo.Posts, [' + @dbname + '].dbo.Users
    WHERE Posts.PostTypeId = 6 AND Posts.OwnerUserId = Users.Id
    ';
  INSERT INTO @output EXEC (@query);*/
  FETCH NEXT FROM dbcursor INTO @dbname;
END

CLOSE dbcursor;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results