This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[help_change_feed]') AND type in (N'U')) DROP TABLE [dbo].[help_change_feed] | |
| create table help_change_feed | |
| ( | |
| table_group_id uniqueidentifier , | |
| table_group_name nvarchar(140) , | |
| destination_location nvarchar(512) , | |
| destination_credential nvarchar(247) , | |
| destination_type nvarchar(247) , | |
| workspace_id nvarchar(247) , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %%pyspark | |
| import sempy.fabric as fabric | |
| import struct | |
| import sqlalchemy | |
| import pyodbc | |
| import pandas as pd | |
| from notebookutils import mssparkutils | |
| #Function to Return sqlalchemt ODBC Engine, given a connection string and using Integrated AAD Auth to Fabric |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @json(' | |
| "translator": { | |
| "type": "TabularTranslator", | |
| "mappings": [ | |
| { | |
| "source": { | |
| "name": "t", | |
| "type": "DateTime", | |
| "physicalType": "datetime" | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from notebookutils import mssparkutils | |
| import sempy.fabric as fabric | |
| from sempy.fabric.exceptions import FabricHTTPException, WorkspaceNotFoundException | |
| import json | |
| from pyspark.sql import SparkSession | |
| from pyspark.sql.types import StructType, StructField, StringType | |
| from datetime import datetime | |
| # Get token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import struct | |
| import sqlalchemy | |
| import pyodbc | |
| import notebookutils | |
| import sempy.fabric as fabric | |
| from sqlalchemy import text | |
| import time | |
| # ----------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| View Migration Script: SQL Server ➜ Fabric Warehouse/Lakehouse | |
| -------------------------------------------------------------- | |
| This script copies one or more view definitions from a source SQL Server database | |
| into a Fabric Warehouse or Lakehouse SQL endpoint. | |
| Key Features: | |
| - Connects to SQL Server using SQLAlchemy/pyodbc. | |
| - Connects to Fabric using MSI authentication (access token). | |
| - Reads view definitions from sys.views/sys.sql_modules in the source. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This is very rough, it doesn't work for ints/bits/etc only varchars | |
| This does not work if there are schema bound views | |
| */ | |
| select 'alter table ' + s.name + '.' + object_name(c.object_id) + ' ALTER COLUMN ' + c.name + ' ' + ttt.name + '(' + convert(varchar,c.max_length) + ');', | |
| c.max_length , c.*, tt.*, s.* from sys.columns c | |
| inner join sys.tables tt on tt.object_id = c.object_id | |
| inner join sys.schemas s on s.schema_id = tt.schema_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Value | Description | Meaning | |
|---|---|---|---|
| Failure | Indicates a failure. | Something when wrong. Check the errors. | |
| NotRun | Indicates that the operation did not run. | We did run - but found no changes to the table. | |
| Success | Indicates a success. | We found a update i.e. a new delta log and updated the SQL Endpoint. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "KeyColumns": [ "_id_" ], | |
| "SchemaDefinition": { | |
| "Columns": [ | |
| { | |
| "Name": "id", | |
| "DataType": "Int32" | |
| }, | |
| { | |
| "Name": "Timestamp", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import notebookutils | |
| import sempy.fabric as fabric | |
| from sempy.fabric.exceptions import FabricHTTPException, WorkspaceNotFoundException | |
| def pad_or_truncate_string(input_string, length, pad_char=' '): | |
| # Truncate if the string is longer than the specified length | |
| if len(input_string) > length: | |
| return input_string[:length] | |
| # Pad if the string is shorter than the specified length |
NewerOlder