In our SQL Server we refresh, every 30 minutes, the below tables using this procedure
`exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' ,'Case' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'Account' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'User' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'RecordType' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'End_Customer__c' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'Access__c' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'Pricing_Entry__c' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'Assets__c' ,'Yes','no'
exec [SalesforceBackup].dbo.SF_Refresh 'SALESFORCE' , 'Component__c' ,'Yes','no'`
This works most of the time, however, when a new field is added to the table via Salesforce. The above stops working, I am then having to use a manual function as a work around to get the code running again.
Our SQL is currently slow and mismanged, is it possible this is part of a larger issue
This is the error that is recieved
` Using last run time of 2022-11-21 13:48:00 [SQLSTATE 01000] (Message 0) 19:15:56: Identified 1123 updated/inserted rows. [SQLSTATE 01000] (Message 0) 19:15:56: Error: Fixed_Asset_Tracking_URL__c exists in the delta table but does not exist in the local table or has a different definition. [SQLSTATE 01000] (Message 0) 19:15:56: Table schema has changed. The table will be replicated instead. [SQLSTATE 01000] (Message 0) --- Starting SF_Replicate for Case V5.1.9 [SQLSTATE 01000] (Message 0) `
The below is what I use to Replicate the table, then I switch back to the Refresh function and it will work again
exec [SalesforceBackup].dbo.SF_Replicate'SALESFORCE' ,'Case','pkchunk,batchsize(7500)'
I believe the Refresh function should be adding the column anyway, but is there a way to automatically solve the error by including teh new column with my manual intervention
Thanks
1条答案
按热度按时间jgwigjjp1#
Because
SF_Refresh
only refreshes the table data, not the table schema.You'll want to either use
SF_Mirror
or have aTRY / CATCH
block on your TSQL code and use bothSF_Refresh
andSF_Replicate
.Check out the documentation for SF_Mirror here
As for the
TRY / CATCH
block as suggested above, this is how we do it at our org using a stored procedure to warehouse our Salesforce dataEDIT: Just realized how old this question is so hopefully this helps out someone :)