Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross Environment Join: Null Reference Exception #520

Closed
clintonbale opened this issue Jul 23, 2024 · 2 comments · Fixed by #531
Closed

Cross Environment Join: Null Reference Exception #520

clintonbale opened this issue Jul 23, 2024 · 2 comments · Fixed by #531

Comments

@clintonbale
Copy link

The following query to join the systemuser table between two environments fails:

select PROD_user.systemuserid, DEV_user.systemuserid
from [PROD CONNECTION].dbo.systemuser PROD_user
join [DEV CONNECTION].dbo.systemuser DEV_user ON DEV_user.domainname = PROD_user.domainname

With the following error:

Msg 10337, Level 16, State 1, Line 1
Object reference not set to an instance of an object.

See the Execution Plan tab for details of where this error occurred

It does work however when joining on the azureactivedirectoryobjectid instead.


  • Deployment: Online
  • DB Version: 9.2.24071.168
  • Connection Controls Version: 1.2023.6.56
  • XrmToolBox Version: 1.2023.12.68
  • Tool Version: 9.2.0.0
@MarkMpn
Copy link
Owner

MarkMpn commented Jul 25, 2024

This is most likely due to different collations being used in the different environments. I'll look at improving the error reporting in the next update, but if this is the problem you can work around it by specifying the collation to use for the comparison, e.g.

select PROD_user.systemuserid, DEV_user.systemuserid
from [PROD CONNECTION].dbo.systemuser PROD_user
join [DEV CONNECTION].dbo.systemuser DEV_user ON DEV_user.domainname = PROD_user.domainname COLLATE Latin1_General_CI_AI

@clintonbale
Copy link
Author

Looks like that was it, specifying the collation does allow the query to work.

Looking into the underlying cause: I'm not sure why these environments have different collations, they were created near the same time with the same settings, same region (Canada), same language (English United States).

DEV has 1033_CI_AI while PROD has 4105_CI_AI

To check I used select SERVERPROPERTY('collation')

@MarkMpn MarkMpn linked a pull request Aug 24, 2024 that will close this issue
@MarkMpn MarkMpn mentioned this issue Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants