3

An error is raised when attempting to run a script generated by Visual Studio's data compare tool. I could not find a solution though Google search.

This happens on all dev machines I have attempted it on in the office.

I am executing it from within Microsoft SQL Sever Management Studio 2006 R2 connecting to a remote server instance over the network.

  • Microsoft SQL Server Management Studio 10.50.2550.0
  • Microsoft Analysis Services Client Tools 10.50.2500.0
  • Microsoft Data Access Components (MDAC) 6.1.7601.17514
  • Microsoft MSXML3.0 4.0 5.0 6.0
  • Microsoft Internet Explorer 9.11.9600.16476
  • Microsoft .NET Framework 2.0.50727.5472
  • Operating System 6.1.7601

Error

Msg 6506, Level 16, State 10, Line 5
Could not find method 'WRITE' for type 'Microsoft.SqlServer.Types.SqlGeography' in assembly 'Microsoft.SqlServer.Types'

SQL

http://pastebin.com/embed_iframe.php?i=R9ResyeX

Just a note that the table column 'Shape' is declared as;

[Shape] [geography] NULL

I attempted to correct the genrated TSQL, I changed .WRITE to .Write as per http://technet.microsoft.com/en-us/library/microsoft.sqlserver.types.sqlgeography.write%28v=sql.105%29.aspx and then removed to two redundant NULL, NULL parameters from the end. Just in case SQL was automagicly turning the hex string into a BinaryWriter that the method expects. This resulted in the expected error;

Msg 6564, Level 16, State 1, Line 1
The method 'Write' in class 'Microsoft.SqlServer.Types.SqlGeography' in assembly 'Microsoft.SqlServer.Types' has some invalid arguments. Value of type 'varbinary(528)' is not valid for argument number 0.

I am not sure, but this looks like a bug in the code compare tool, where it is generating invalid SqlGeography SQL commands ?

If we remove the '.WRITE' altogether and leave just the = operator, this looks like the way the TSQL should coerce the hex value, since it gets further. However then we get another error.

Msg 6522, Level 16, State 1, Line 13
A .NET Framework error occurred during execution of user-defined routine or aggregate "geometry": 
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
System.IO.EndOfStreamException: 
   at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
   at System.IO.BinaryReader.ReadDouble()
   at Microsoft.SqlServer.Types.GeoData.Read(BinaryReader r)
   at SqlGeometry::.DeserializeValidate(IntPtr , Int32 , CClrLobContext* )

The only article I have found touching on this error was this;

http://blogs.msdn.com/b/isaac/archive/2009/08/10/spatial-data-type-structure.aspx

However I am none the wiser when it comes to the HEX that Visual Studio has extracted from the source data table.

Microsoft Developer
  • 1,919
  • 1
  • 20
  • 27

0 Answers0