Advertisement
Fhernd

ComparacionTablas.sql

Jul 7th, 2016
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 1.66 KB | None | 0 0
  1. SELECT *,
  2.     COUNT(*) AS 'Contador Duplicados',
  3.     'Password' AS  'Nombre Tabla'
  4.     FROM Person.Password P
  5.     GROUP BY BusinessEntityID,
  6.         PasswordHash,
  7.         PasswordSalt,
  8.         rowguid,
  9.         ModifiedDate
  10.     HAVING NOT EXISTS (
  11.         SELECT *,
  12.             COUNT(*)
  13.             FROM Person.CopiaPassword PC
  14.             GROUP BY BusinessEntityID,
  15.                 PasswordHash,
  16.                 PasswordSalt,
  17.                 rowguid,
  18.                 ModifiedDate
  19.             HAVING PC.BusinessEntityID = P.BusinessEntityID
  20.                 AND PC.PasswordHash = P.PasswordHash
  21.                 AND PC.PasswordSalt = P.PasswordSalt
  22.                 AND PC.rowguid = P.rowguid
  23.                 AND PC.ModifiedDate = P.ModifiedDate
  24.                 AND COUNT(*) = COUNT(ALL P.BusinessEntityID))
  25. UNION
  26. SELECT *,
  27.     COUNT(*) AS 'Contador Duplicados',
  28.     'CopiaPassword' AS 'Nombre Tabla'
  29.     FROM Person.CopiaPassword PC
  30.     GROUP BY BusinessEntityID,
  31.         PasswordHash,
  32.         PasswordSalt,
  33.         rowguid,
  34.         ModifiedDate
  35.     HAVING NOT EXISTS (
  36.         SELECT *,
  37.             COUNT(*)
  38.             FROM Person.Password P
  39.             GROUP BY BusinessEntityID,
  40.                 PasswordHash,
  41.                 PasswordSalt,
  42.                 rowguid,
  43.                 ModifiedDate
  44.             HAVING PC.BusinessEntityID = P.BusinessEntityID
  45.                 AND PC.PasswordHash = P.PasswordHash
  46.                 AND PC.PasswordSalt = P.PasswordSalt
  47.                 AND PC.rowguid = P.rowguid
  48.                 AND PC.ModifiedDate = P.ModifiedDate
  49.                 AND COUNT(*) = COUNT(ALL PC.BusinessEntityID));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement