CHADI E. answered 12/22/23
PhD in Engineering, extensive industry experience and desire to help
I suggest you try one of the following:
a- Use STIsValidReason(YourGeometry) to indenitfy what is causing the invalid error and fix accordingly.
b- Split into Valid LineStrings:
1-Use STSplit(YourGeometry) to create separate valid LineStrings.
2-Apply MakeValid to each valid LineString, and convert to Geography instances.
3-use STUnion() to merge the individual Geography instances.