{"id":24546646,"url":"https://github.com/devizer/universe.sqlserverjam","last_synced_at":"2025-03-16T10:18:05.725Z","repository":{"id":74856675,"uuid":"109147377","full_name":"devizer/Universe.SqlServerJam","owner":"devizer","description":"Package implements: discovering local sql server instances by the same way as SSMS and operations during unit testing: start, stop services, check server edition, forced database delete, checking databases size, recovery mode, auto shrinking, etc.","archived":false,"fork":false,"pushed_at":"2025-03-16T06:56:57.000Z","size":3258,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T07:27:40.022Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devizer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-01T15:16:41.000Z","updated_at":"2025-03-16T06:57:00.000Z","dependencies_parsed_at":"2024-04-19T00:24:32.750Z","dependency_job_id":"f4800733-9bb2-4d59-8d48-86625995cc0a","html_url":"https://github.com/devizer/Universe.SqlServerJam","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devizer%2FUniverse.SqlServerJam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devizer%2FUniverse.SqlServerJam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devizer%2FUniverse.SqlServerJam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devizer%2FUniverse.SqlServerJam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devizer","download_url":"https://codeload.github.com/devizer/Universe.SqlServerJam/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243852598,"owners_count":20358274,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-22T22:16:22.174Z","updated_at":"2025-03-16T10:18:05.624Z","avatar_url":"https://github.com/devizer.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Universe.SqlServerJam\nOperations during unit testing: start, stop services, check server edition, forced database delete, checking databases size, recovery mode, auto shrinking, etc. Discovering local sql server instances by the same way as SSMS\n\n## IDbConnection.Manage() Extensions\n\n| Data Type | Member | comments |\n|-----------|--------|----------|\n| Version | ShortServerVersion { get; } | @@MICROSOFTVERSION |\n| string | ProductVersion { get; } | GetServerProperty\u003cstring\u003e(\"ProductVersion\") |\n| string | ProductLevel { get; } | CTP, RTM, SP1, SP2, ... |\n| string | ProductUpdateLevel { get; } | CU1, CU2, ... |\n| string | LongServerVersion { get; } | @@VERSION |\n| string    | ServerEdition { get; } | \"SQL Azure\", \"Express Edition\", \"Developer Edition\", \"Enterprise Edition\", ...\n| EngineEdition | EngineEdition { get; }| Personal, Standard, Exterprise, Express, SqlDatabase, SqlDataWarehouse |\n| bool | IsLocalDB { get; } |\n| bool | IsAzure { get; } |\n| bool | IsCompressedBackupSupported { get; } | ShortServerVersion.Major \u003e= 10 \u0026\u0026 EngineEdition == Enterprise |\n| bool | IsFullTextSearchInstalled { get; } |\n| bool | IsConnectionEncrypted { get; } |\n| SecurityMode| SecurityMode { get; } | IntegratedOnly, Both |\n| string | HostPlatform { get; } | \"Windows\", \"Linux\" |\n| FixedServerRoles | FixedServerRoles { get; } | SysAdmin, SetupAdmin, ServerAdmin, SecurityAdmin, ProcessAdmin, ... |\n| string | NetTransport { get; } | \"TCP\", \"Shared Memory\", \"Named Pipe\" |\n| int | CurrentSPID | @@SPID |\n| string | CurrentDatabaseName { get; } | DB_NAME() |\n| DatabaseOptionsManagement | CurrentDatabase { get; } | .Databases[CurrentDatabaseName] |\n| double | Ping(int timeout = 20) | returns roundtrip duration |\n| SqlDefaultPaths | DefaultPaths { get; } | Data, Logs and Backups default folder. By default SQL Server process has permissions to this folders only. Not applicable for Azure |\n\nSqlServerManagement Manage(this IDbConnection) contains following public members:\n```csharp\nVersion ShortServerVersion { get; }                      │ @@MICROSOFTVERSION\nstring ProductVersion { get; }                           │ \nstring ProductUpdateLevel { get; }                       │ CU1, CU2, ... \nstring ProductLevel { get; }                             │ CTP, RTM, SP1, SP2, ... \nstring LongServerVersion { get; }                        │ @@VERSION \nstring ServerEdition { get; }                            │ \"SQL Azure\", \"Express Edition\", \"Developer Edition\", \"Enterprise Edition\", ...\nEngineEdition EngineEdition { get; }                     │ Personal | Standard | Exterprise | Express | SqlDatabase | SqlDataWarehouse\nbool IsLocalDB { get; }                                  │\nbool IsAzure { get; }                                    │\nbool IsCompressedBackupSupported { get; }                │ ShortServerVersion.Major \u003e= 10 \u0026\u0026 EngineEdition == Enterprise \nstring ServerCollation { get; }                          |\nbool IsFullTextSearchInstalled { get; }                  │\nbool IsConnectionEncrypted { get; }                      │\nSecurityMode SecurityMode { get; }                       │ Either IntegratedOnly or Both\nSqlDefaultPaths DefaultPaths { get; }                    │ Data, Logs and Backups default folder. Not applicable for Azure DB\nstring HostPlatform { get; }                             │ Either \"Windows\" or \"Linux\"\nFixedServerRoles FixedServerRoles { get; }               │ SysAdmin | SetupAdmin | ServerAdmin, ...\nstring NetTransport { get; }                             │ Either \"TCP\", \"Shared Memory\" or \"Named Pipe\" \nint CurrentSPID { get; }                                 │ @@SPID\ndouble Ping(int timeout = 20)                            │ Returns roundtrip duration in seconds\nstring CurrentDatabaseName { get; }                      │ DB_NAME() \nDatabaseOptionsManagement CurrentDatabase { get; }       │ Databases[CurrentDatabaseName] \nDatabaseOptionsManagement Databases[\"Contoso\"] { get; }  │\n```\n\n\n## Full Featured Demo\nSource code: [Full_Featured_Demo.cs](https://github.com/devizer/Universe.SqlServerJam/blob/master/Universe.SqlServerJam/Universe.SqlServerJam.Tests/Full_Featured_Demo.cs)\n\n## SqlDiscovery\nIt is *a* first person class of the library.\nIt's purpose to find local installed SQL Server, icluding x86 and x64 families.\n```csharp\npublic static List\u003cSqlServerRef\u003e GetLocalDbAndServerList() { ... }\n\npublic class SqlServerRef\n{\n    public SqlServerDiscoverySource Kind { get; set; }\n    public Version Version { get; set; }\n    public string ConnectionString { get; }\n}\n\npublic enum SqlServerDiscoverySource\n{\n    Local,\n    LocalDB,\n    WellKnown\n}\n\n```\n\nAlso it finds default MSSQLLocalDB instance of LocalDB 2012 ... 2016.\nOptionally for integration tests a network/cloud SQL Servers might be injectec into descory proc using environvent variables. For example:\n```\nset SQLSERVER_WELLKNOWN_Linux=Server=tcp:Ubuntu-16.04-LTS,1433;User Id=sa;Password=your!passw0rd\nset SQLSERVER_WELLKNOWN_Azure_EU=Server=tcp:my-server.database.windows.net,1433;Initial Catalog=MyDb;Persist Security Info=False;User ID=\u003cuser\u003e;Password=\u003cpassword\u003e;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;\n```\n\nHere is a sample output\n```cs\nvar sqlServers = SqlDiscovery.GetLocalDbAndServerList().OrderByVersionDesc().ToList();\nConsole.WriteLine(sqlServers.AsBullets());\n```\n\n```\n * tcp:Ubuntu-16.04-LTS,1433 (14.0.3006)\n * (local)\\SQLEXPRESS (14.0.1000.169)\n * tcp:my-server-eu.database.windows.net,1433 (14.0.900)\n * tcp:my-server-frankfurt.blablahash.eu-central-1.rds.amazonaws.com,1433 (13.0.4422)\n * (LocalDB)\\MSSqlLocalDB (13.0)\n * tcp:my-server-oregon.blablahash.rds.amazonaws.com,1433 (10.50.2789)\n * (local)\\SQL2008R2 (10.50.1600.1)\n * (local)\\SQL2005 (9.0.5000.0)\n```\n\nThe bullet list above of (local) and (localdb) servers was discovered automatically using registry, and rest of servers where injected using `SQLSERVER_WELLKNOWN_` env vars.\n\n## SqlExtentions\nHere is a sample output of IDbConnection extentions on Azure DB\n```\nVersion (32-bit) .........: 14.0.900\nVersion (string) .........: 12.0.2000.8\nProduct Level ............: RTM\nUpdate Level .............: \nEdition ..................: SQL Azure\nEngine Edition ...........: SQL_Database\nHost Platform ............: Windows\nSecurity Mode ............: Both\nIs LocalDB ...............: False\nTransport ................: TCP, Encrypted\nServer Collation .........: SQL_Latin1_General_CP1_CI_AS\nBuilt-in Roles ...........: None\nDatabases ................: 1 (4512 Kb)\nDefault Data .............: \nDefault Log ..............: \nDefault Backup ...........: \nConnected DB Info ........: [MySandBox]\n  - Auto Shrink ......... : False\n  - Auto Create Statistic : Complete\n  - Auto Update Statistic : Syncly\n  - Recursive Triggers .. : False\n  - Broker Enabled ...... : True\n  - State ............... : Online\n  - Is Readonly ......... : False\n  - Default Collation ... : SQL_Latin1_General_CP1_CI_AS [IgnoreCase, IgnoreKana, IgnoreWidth]\n  - Size (KB) ........... : 4512\n  - Recovery Mode ....... : Full\n  - Owner ............... : Not Applicable\n  - AZ Edtion ........... : Standard\n  - AZ Service Objective. : S1\n  - AZ Elastic Pool ..... : \nLong Version .............: Microsoft SQL Azure (RTM) - 12.0.2000.8 Aug 29 2017 13:06:11 Copyright (C) 2017 Microsoft Corporation \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevizer%2Funiverse.sqlserverjam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevizer%2Funiverse.sqlserverjam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevizer%2Funiverse.sqlserverjam/lists"}