{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [ { "data": { "text/html": [ "
Installed Packages
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/markdown": [ "Loading extensions from `Microsoft.DotNet.Interactive.SqlServer.dll`" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
Query Microsoft SQL Server databases.\r\n", "

This extension adds support for connecting to Microsoft SQL Server databases using the #!connect mssql magic command. For more information, run a cell using the #!sql magic command.

\r\n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#r \"nuget: Microsoft.DotNet.Interactive.SqlServer, *-*\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [], "source": [ "var connectionString = Environment.GetEnvironmentVariable(\"TEST_MSSQL_CONNECTION_STRING\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [ { "data": { "text/plain": [ "Kernel added: #!sql-adventureworks" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#!connect mssql --kernel-name adventureworks @csharp:connectionString " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [], "source": [ "#!value --name country_region_code --from-value @input:country_region_code" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [ { "data": { "text/plain": [ "Adding shared variable declaration statement : DECLARE @territory_name NVarChar(2) = N'US';" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "Adding shared variable declaration statement : DECLARE @country_region_code NVarChar(2) = N'US';" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "(8 rows affected)" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/csv": [ "BusinessEntityID,TerritoryID,SalesQuota,Bonus,CommissionPct,SalesYTD,SalesLastYear,rowguid,ModifiedDate,TerritoryID (2),Name,CountryRegionCode,Group,SalesYTD (2),SalesLastYear (2),CostYTD,CostLastYear,rowguid (2),ModifiedDate (2)\r\n", "275,2,300000.0000,4100.0000,0.0120,3763178.1787,1750406.4785,1e0a7274-3064-4f58-88ee-4c6586c87169,2011-05-24T00:00:00.0000000,2,Northeast,US,North America,2402176.8476,3607148.9371,0.0000,0.0000,00fb7309-96cc-49e2-8363-0a1ba72486f2,2008-04-30T00:00:00.0000000\r\n", "276,4,250000.0000,2000.0000,0.0150,4251368.5497,1439156.0291,4dd9eee4-8e81-4f8c-af97-683394c1f7c0,2011-05-24T00:00:00.0000000,4,Southwest,US,North America,10510853.8739,5366575.7098,0.0000,0.0000,dc3e9ea0-7950-4431-9428-99dbcbc33865,2008-04-30T00:00:00.0000000\r\n", "277,3,250000.0000,2500.0000,0.0150,3189418.3662,1997186.2037,39012928-bfec-4242-874d-423162c3f567,2011-05-24T00:00:00.0000000,3,Central,US,North America,3072175.1180,3205014.0767,0.0000,0.0000,df6e7fd8-1a8d-468c-b103-ed8addb452c1,2008-04-30T00:00:00.0000000\r\n", "279,5,300000.0000,6700.0000,0.0100,2315185.6110,1849640.9418,52a5179d-3239-4157-ae29-17e868296dc0,2011-05-24T00:00:00.0000000,5,Southeast,US,North America,2538667.2515,3925071.4318,0.0000,0.0000,6dc4165a-5e4c-42d2-809d-4344e0ac75e7,2008-04-30T00:00:00.0000000\r\n", "280,1,250000.0000,5000.0000,0.0100,1352577.1325,1927059.1780,be941a4a-fb50-4947-bda4-bb8972365b08,2011-05-24T00:00:00.0000000,1,Northwest,US,North America,7887186.7882,3298694.4938,0.0000,0.0000,43689a10-e30b-497f-b0de-11de20267ff7,2008-04-30T00:00:00.0000000\r\n", "281,4,250000.0000,3550.0000,0.0100,2458535.6169,2073505.9999,35326ddb-7278-4fef-b3ba-ea137b69094e,2011-05-24T00:00:00.0000000,4,Southwest,US,North America,10510853.8739,5366575.7098,0.0000,0.0000,dc3e9ea0-7950-4431-9428-99dbcbc33865,2008-04-30T00:00:00.0000000\r\n", "283,1,250000.0000,3500.0000,0.0120,1573012.9383,1371635.3158,6bac15b2-8ffb-45a9-b6d5-040e16c2073f,2011-05-24T00:00:00.0000000,1,Northwest,US,North America,7887186.7882,3298694.4938,0.0000,0.0000,43689a10-e30b-497f-b0de-11de20267ff7,2008-04-30T00:00:00.0000000\r\n", "284,1,300000.0000,3900.0000,0.0190,1576562.1966,0.0000,ac94ec04-a2dc-43e3-8654-dd0c546abc17,2012-09-23T00:00:00.0000000,1,Northwest,US,North America,7887186.7882,3298694.4938,0.0000,0.0000,43689a10-e30b-497f-b0de-11de20267ff7,2008-04-30T00:00:00.0000000\r\n" ], "text/html": [ "
BusinessEntityIDTerritoryIDSalesQuotaBonusCommissionPctSalesYTDSalesLastYearrowguidModifiedDateTerritoryID (2)NameCountryRegionCodeGroupSalesYTD (2)SalesLastYear (2)CostYTDCostLastYearrowguid (2)ModifiedDate (2)
275
2
300000.0000
4100.0000
0.0120
3763178.1787
1750406.4785
1e0a7274-3064-4f58-88ee-4c6586c87169
2011-05-24 00:00:00Z
2
NortheastUSNorth America
2402176.8476
3607148.9371
0.0000
0.0000
00fb7309-96cc-49e2-8363-0a1ba72486f2
2008-04-30 00:00:00Z
276
4
250000.0000
2000.0000
0.0150
4251368.5497
1439156.0291
4dd9eee4-8e81-4f8c-af97-683394c1f7c0
2011-05-24 00:00:00Z
4
SouthwestUSNorth America
10510853.8739
5366575.7098
0.0000
0.0000
dc3e9ea0-7950-4431-9428-99dbcbc33865
2008-04-30 00:00:00Z
277
3
250000.0000
2500.0000
0.0150
3189418.3662
1997186.2037
39012928-bfec-4242-874d-423162c3f567
2011-05-24 00:00:00Z
3
CentralUSNorth America
3072175.1180
3205014.0767
0.0000
0.0000
df6e7fd8-1a8d-468c-b103-ed8addb452c1
2008-04-30 00:00:00Z
279
5
300000.0000
6700.0000
0.0100
2315185.6110
1849640.9418
52a5179d-3239-4157-ae29-17e868296dc0
2011-05-24 00:00:00Z
5
SoutheastUSNorth America
2538667.2515
3925071.4318
0.0000
0.0000
6dc4165a-5e4c-42d2-809d-4344e0ac75e7
2008-04-30 00:00:00Z
280
1
250000.0000
5000.0000
0.0100
1352577.1325
1927059.1780
be941a4a-fb50-4947-bda4-bb8972365b08
2011-05-24 00:00:00Z
1
NorthwestUSNorth America
7887186.7882
3298694.4938
0.0000
0.0000
43689a10-e30b-497f-b0de-11de20267ff7
2008-04-30 00:00:00Z
281
4
250000.0000
3550.0000
0.0100
2458535.6169
2073505.9999
35326ddb-7278-4fef-b3ba-ea137b69094e
2011-05-24 00:00:00Z
4
SouthwestUSNorth America
10510853.8739
5366575.7098
0.0000
0.0000
dc3e9ea0-7950-4431-9428-99dbcbc33865
2008-04-30 00:00:00Z
283
1
250000.0000
3500.0000
0.0120
1573012.9383
1371635.3158
6bac15b2-8ffb-45a9-b6d5-040e16c2073f
2011-05-24 00:00:00Z
1
NorthwestUSNorth America
7887186.7882
3298694.4938
0.0000
0.0000
43689a10-e30b-497f-b0de-11de20267ff7
2008-04-30 00:00:00Z
284
1
300000.0000
3900.0000
0.0190
1576562.1966
0.0000
ac94ec04-a2dc-43e3-8654-dd0c546abc17
2012-09-23 00:00:00Z
1
NorthwestUSNorth America
7887186.7882
3298694.4938
0.0000
0.0000
43689a10-e30b-497f-b0de-11de20267ff7
2008-04-30 00:00:00Z
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#!sql-adventureworks\n", "#!share --from value country_region_code\n", "\n", "select * from Sales.SalesPerson left join Sales.SalesTerritory on Sales.SalesPerson.TerritoryID = Sales.SalesTerritory.TerritoryID\n", " where CountryRegionCode = @country_region_code" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [], "source": [ "#!share --from sql-adventureworks territories\n", "territories" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [], "source": [ "#r \"nuget: SandDance.InteractiveExtension, 1.0.45\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [], "source": [ "adventureworks.SalesPeople.ExploreWithSandDance()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "dotnet_interactive": { "language": "csharp" }, "vscode": { "languageId": "dotnet-interactive.csharp" } }, "outputs": [], "source": [ "territories" ] } ], "metadata": { "kernelspec": { "display_name": ".NET (C#)", "language": "C#", "name": ".net-csharp" }, "language_info": { "file_extension": ".cs", "mimetype": "text/x-csharp", "name": "C#", "pygments_lexer": "csharp", "version": "9.0" } }, "nbformat": 4, "nbformat_minor": 4 }