Wednesday, February 26, 2025

Azure - CETAS with OPENQUERY works!

 Just putting it here since I'm thrilled this weird way of doing it worked. 

I was trying to use a linked server from an MI to an Azure SQL DB, so that I could CETAS (Create External Table As Select) from my Azure SQL DB to blob storage (since the only way to do it from ASD is either ADF or some sort of preview thing). It didn't work. Closest I got was XML errors on distributed queries. Then I went to OPENQUERY Woot! And I even got the xml field copied over!




CREATE EXTERNAL TABLE mytablename

WITH (

    LOCATION = 'capture/20250226/01',

    DATA_SOURCE = [my_blob_data_source],

    FILE_FORMAT = CETAS_ParquetSN_FileFormat)

AS 

SELECT fielda, fieldb, fieldc FROM OPENQUERY(my_ro_linked_server,'SELECT fielda, fieldb,  convert(nvarchar(max),fieldc) as fieldc FROM capture.dbo.mytable')




No comments: