SqlServerExplorerLib 1.7.0

dotnet add package SqlServerExplorerLib --version 1.7.0
                    
NuGet\Install-Package SqlServerExplorerLib -Version 1.7.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlServerExplorerLib" Version="1.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqlServerExplorerLib" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="SqlServerExplorerLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SqlServerExplorerLib --version 1.7.0
                    
#r "nuget: SqlServerExplorerLib, 1.7.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SqlServerExplorerLib@1.7.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SqlServerExplorerLib&version=1.7.0
                    
Install as a Cake Addin
#tool nuget:?package=SqlServerExplorerLib&version=1.7.0
                    
Install as a Cake Tool

SqlServerExplorerLib

Low-level, async-first SQL Server operations with minimal overhead.

SqlServerExplorerLib is focused on practical data access tasks such as:

  • validating connectivity,
  • inspecting tables and columns,
  • running raw SQL queries,
  • exporting DataTable results to delimited files,
  • and performing fast bulk-copy transfers between sources.

Installation

Package Manager:

Install-Package SqlServerExplorerLib

.NET CLI:

dotnet add package SqlServerExplorerLib

Quick start

using SqlServerExplorerLib;
using System.Data;

var sql = new SqlServerExplorer();
string cs = "my_connection_string";

Dependency injection is also supported:

var host = Host
    .CreateDefaultBuilder()
    .ConfigureServices(services => services.AddSingleton<SqlServerExplorer>())
    .Build();

var logger = host.Services.GetRequiredService<ILoggerFactory>().CreateLogger("SQLServerExplorer");
var configuration = host.Services.GetRequiredService<IConfiguration>();

string cs = configuration.GetConnectionString("Default")!;
var sql = host.Services.GetRequiredService<SqlServerExplorer>();
string tableName = "TEST_TABLE";

Core capabilities

Connectivity

bool ok = await sql.TestConnection(cs);

Optional timeout:

bool ok = await sql.TestConnection(cs, timeoutInSeconds: 5);

Schema exploration

  • GetTables(connectionString)
  • GetFields(connectionString, SqlServerTable)
  • TableExists(connectionString, tableName)
List<SqlServerTable> tables = await sql.GetTables(cs);
var myTable = tables.First(t => t.Name == tableName);
List<SqlServerField> fields = await sql.GetFields(cs, myTable);

Record and table utilities

  • IsTableEmpty(connectionString, tableName)
  • GetRecordsCount(connectionString, tableName)
  • GetRecordsCount(connectionString, SqlServerTable)
  • TruncateTable(connectionString, tableName)

Raw SQL operations

SqlServerExplorer supports both plain and parameterized overloads:

  • Execute(...)
  • Query(...)
  • QueryScalar<T>(...)
await sql.Execute(cs, "create table [TEST_TABLE](id int, name nvarchar(50), value float)");

int count = await sql.QueryScalar<int>(cs, "select count(*) from [TEST_TABLE]");

DataTable data = await sql.Query(cs, "select * from [TEST_TABLE]");

Data preview and export

  • GetTopRecords(connectionString, table, count)
  • QueryToFile(connectionString, sqlText, targetFile, fieldSeparator)
  • SaveToFile(DataTable, targetFile, fieldSeparator)
DataTable preview = await sql.GetTopRecords(cs, myTable, count: 200);
DataTable all = await sql.QueryToFile(cs, "select * from [TEST_TABLE]", "./mydata.csv", ";");
sql.SaveToFile(all, "./mydata.csv", ";");

Bulk copy

Use high-throughput copy operations with global settings:

  • BatchSize
  • BulkCopyTimeoutInSeconds
  • LoadedData event
  • CopyTo(targetConnectionString, DataTable, destinationTableName)
  • CopyTo(sourceConnectionString, targetConnectionString, SqlServerTable, destinationTableName?)
sql.BulkCopyTimeoutInSeconds = 0; // 0 = no timeout
sql.BatchSize = 0; // 0 = all rows in one batch

sql.LoadedData += (_, _) => logger.LogInformation("Data has been loaded.");
await sql.CopyTo(cs, all, destinationTableName: "OTHER_TABLE");

Additional existing capabilities

SqlServerService base class (advanced/low-level)

For custom services, derive from SqlServerExplorerLib.DataServices.SqlServerService and use:

  • GetDataTable
  • GetDataSet
  • GetScalar<T>
  • ExecuteNonQuery
  • GetList<T>
  • GetStringList
  • GetSingleRow
  • BulkCopy

This provides a low-level async API while keeping full control of SQL and mapping.

Data conversion helpers

Namespace: SqlServerExplorerLib.DataServices

  • DataTableExtensions.ToList<T>()
  • DataTableExtensions.ToArray<T>()
  • DataTableExtensions.ToStringArray(useEmptyStringForNull)
  • DataTableExtensions.ToStringList(useEmptyStringForNull)
  • DataRowExtensions.ForceReadDouble/Int/String/Bool/DateTime(...)
  • DataRowExtensions.SafeReadEnum<T>(...)

Metadata models

  • SqlServerTable (schema + name + formatted [schema].[name] output)
  • SqlServerField (position, CLR type, SQL type, max length, nullability)

Notes

  • Most operations are async and intended to be awaited.
  • A defensive try/catch around integration code is recommended.
  • For best safety, prefer parameterized SQL overloads whenever possible.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.7.0 98 7/15/2026
1.6.9 318 2/21/2025
1.6.8 237 2/5/2025
1.6.7 218 2/5/2025
1.6.5 223 2/5/2025
1.6.4 217 2/5/2025
1.6.3 218 12/21/2024
1.6.2 294 12/7/2024
1.6.1 226 12/7/2024
1.6.0 224 12/7/2024
1.5.0 216 12/7/2024
1.3.0 239 7/27/2024
1.2.1 343 10/15/2023
1.2.0 243 10/15/2023
1.1.0 250 10/15/2023