I'm working in restructure a partinioned table so I have two tables with the same schema, for ensuring the insert process was executed succesfully without change some value i want to validate that the registers are equals into two tables.
This is the schema for two tables
CREATE TABLE [dbo].[PerformanceSummary](
[CountryName] [varchar](100) NULL,
[RegionName] [varchar](100) NULL,
[CustomerName] [varchar](10) NULL,
[ProviderName] [varchar](10) NULL,
[Dia] [datetime] NULL,
[CallsNumber] [float] NULL,
[Charge] [float] NULL,
[ChargeMinutes] [float] NULL,
[Cost] [float] NULL,
[CostMinutes] [float] NULL,
[ACD] [float] NULL,
[ASR] [float] NULL,
[PDD] [float] NULL,
[AAR] [float] NULL,
[PSC] [float] NULL,
[IsBillable] [int] NULL,
[IsFailure] [int] NULL,
[EsLatam] [bit] NULL,
[Segmento] [varchar](100) NULL,
[Subsegmento] [varchar](100) NULL,
[CustomerBillingGroup] [varchar](max) NULL,
[CustomerTrafficDesc] [varchar](80) NULL,
[ProviderTrafficDesc] [varchar](80) NULL,
[AccountManager] [varchar](30) NULL,
[CustomerSLBR] [int] NULL,
[ProviderAccountManager] [varchar](30) NULL,
[ProviderSLBR] [int] NULL,
[TipoTrafico] [varchar](10) NULL,
[ValorSemanaLaboral] [varchar](30) NULL,
[ValorSemana] [varchar](30) NULL,
[DayAndHour] [datetime] NOT NULL,
[Clasificacion] [varchar](100) NULL,
[GeographicZone] [varchar](100) NULL,
[IsMerged] [tinyint] NULL,
[Product] [varchar](55) NULL)
I'm triyng to execute the inner join in this way, but I obtained an issue:
SELECT CAST(COUNT(*) AS bigint) AS Total
FROM PerformanceSummary PS
INNER JOIN PerformanceSummaryOLD PSO ON PS.DayAndHour = PSO.DayAndHour;
Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type int
How can I use the sentence COUNT when execute the inner join with datetime colums?
DayAndHour
value exist in both tables. Your query is suspect which may be the cause of the overflow.