locked
Coversion error from geometry to binary? RRS feed

  • Question

  • Hello, I'm new to this forum and SQL Server Spatial. This ia probably an obvious question but... I have some t-sql

    declare

     

    @address geometry

    set

     

    @address =  {some t-sql which retrives a geometry point in WKB form like: (example result)  0x27690000010C9C33A2749DC41A41C364AAC86DB45241 }

    then if I try to convert it to text

    declare

     

    @aHouse geometry

    set

     

    @aHouse = geometry::STGeomFromWKB(@address,0)

    select

     

    @aHouse.STAsText()

    I get this error (failing on the set @house = ... )

    Implicit conversion from data type geometry to varbinary is not allowed. Use the CONVERT function to run this query.

    Wednesday, November 10, 2010 6:52 PM

Answers

  • one more time... here's the one that worked

    set

     

    @aHouse = geometry::STGeomFromText(@address.STAsText(),0)

    btw tanoshimi, I really like your book!

    • Marked as answer by Tom Li - MSFT Friday, November 12, 2010 11:10 AM
    Wednesday, November 10, 2010 8:00 PM

All replies

  • Oops just realized what I needed to do.  It's @aHouse = geometry::STGeomFromWKB(@address.STAsBinary(),0) Thanks for listening!

    Wednesday, November 10, 2010 7:07 PM
  • oops again... It's actually  @aHouse = geometry::STGeomFromText(@address.STAsBinary(),0) Thanks for listening!
    Wednesday, November 10, 2010 7:58 PM
  • one more time... here's the one that worked

    set

     

    @aHouse = geometry::STGeomFromText(@address.STAsText(),0)

    btw tanoshimi, I really like your book!

    • Marked as answer by Tom Li - MSFT Friday, November 12, 2010 11:10 AM
    Wednesday, November 10, 2010 8:00 PM
  • btw tanoshimi, I really like your book!
    Why thankyou - that's very kind. And I'm glad that you solved your problem!
    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Wednesday, November 10, 2010 10:36 PM
    Answerer