Retrieve varbinary value as BASE64 in MSSQL

前端 未结 4 934
旧巷少年郎
旧巷少年郎 2020-12-10 13:46

I\'m looking for a way for retrieving Entity Data Model (EDM) from __MigrationHistory table using only T-SQL (so anyone, using Microsoft SQL Se

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 14:38

    Finally found this article:

    https://social.technet.microsoft.com/wiki/contents/articles/36388.transact-sql-convert-varbinary-to-base64-string-and-vice-versa.aspx#Convert_VARBINARY_to_Base64_String

    So, running the query gets what I wanted, valid Base64.

    Using XML and the hint "for xml path"

    select Model, baze64
    from __MigrationHistory
    cross apply (select Model as '*' for xml path('')) T (baze64)
    

    Other presented queries in article will also work

    Using XML XQuery

    Using JSON

提交回复
热议问题