I have the following query:
CAST(r.ContractID AS NVARCHAR) + '-' + CAST(r.repID AS NVARCHAR)
FROM #recon r
INNER JOIN SalesForceLocal.dbo.[User] AS u with (nolock) ON r.RepId = u.Employee_ID__c
LEFT JOIN salesforcelocal.dbo.Account AS a WITH (NOLOCK) ON r.SPID = a.SPID__c
LEFT JOIN SalesForceLocal.dbo.Opportunity AS o with (nolock) ON r.ContractId = o.Contract_ID__c
ContractID is an integer field in the #recon temp table I created. I need to create an external primary key, so I created concatenation of the RepId (which an int too) and ContractId. I'm having issues now because I need to use ContractId as a field to join onto the Opportunity table. Since I changed it to a nvarchar, it refuses to join now. I was just going to create another temp table and join it on there, but I know there has to be an easier way to do this. Any suggestions?