问题
After installing VS2015, SQL Server can no longer call ToString() method for hierarchyid CLR type - for some values it works, for others it throws the following exception:
A .NET Framework error occurred during execution of user-defined routine or aggregate "hierarchyid": Microsoft.SqlServer.Types.HierarchyIdException: 24000: SqlHierarchyId operation failed because HierarchyId object was constructed from an invalid binary string.
This is easily reproduced by running the following simple query:
select OrganizationNode.ToString() from HumanResources.Employee
I tried uninstalling .NET 4.5.3, but it didn't help. Any known workarounds? Trying to CAST the hierarchyid value to VARCHAR resulted with the same error, so I assume it calls ToString() under the hood.
回答1:
Visual Studio 2015 CTP6 fixes this.
Edit: Changed CTP5 (which did fix it for a short while) to CTP6, which fixes it permanently for me.
来源:https://stackoverflow.com/questions/27588948/visual-studio-2015-preview-breaks-sql-server-hierarchyid