Skip to content

Instantly share code, notes, and snippets.

@UstDoesTech
Created February 22, 2022 08:38
Show Gist options
  • Save UstDoesTech/eebdac85a5f7e979bb2ce04b253b6487 to your computer and use it in GitHub Desktop.
Save UstDoesTech/eebdac85a5f7e979bb2ce04b253b6487 to your computer and use it in GitHub Desktop.
CREATE PROCEDURE Operation.CreateDeltaView
(
@QualifiedName NVARCHAR(300),
@Location NVARCHAR(200)
)
AS
DECLARE @DropStatement NVARCHAR(MAX) = 'DROP VIEW IF EXISTS '+ @QualifiedName +';'
PRINT (@DropStatement)
EXEC sp_executesql @DropStatement
DECLARE @CreateStatement NVARCHAR(MAX) = 'CREATE VIEW ' + @QualifiedName + ' AS
SELECT * FROM
OPENROWSET(
BULK ''' + @Location + ''',
DATA_SOURCE = ''DataLakeMI'',
FORMAT = ''DELTA''
) AS [result]'
PRINT (@CreateStatement)
EXEC sp_executesql @CreateStatement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment