{"id":18244377,"url":"https://github.com/dataplat/invoke-sqlcmd2","last_synced_at":"2025-04-04T13:31:22.627Z","repository":{"id":72634335,"uuid":"68952932","full_name":"dataplat/Invoke-SqlCmd2","owner":"dataplat","description":"PowerShell module containing Invoke-SqlCmd2","archived":false,"fork":false,"pushed_at":"2023-06-23T18:52:06.000Z","size":116,"stargazers_count":68,"open_issues_count":18,"forks_count":35,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-03-20T13:41:50.814Z","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/dataplat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-09-22T19:00:31.000Z","updated_at":"2025-03-15T01:15:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1882225-7094-4a46-9b7e-fcd5b78d4120","html_url":"https://github.com/dataplat/Invoke-SqlCmd2","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/dataplat%2FInvoke-SqlCmd2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2FInvoke-SqlCmd2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2FInvoke-SqlCmd2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataplat%2FInvoke-SqlCmd2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataplat","download_url":"https://codeload.github.com/dataplat/Invoke-SqlCmd2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247185003,"owners_count":20897875,"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":"2024-11-05T09:16:29.861Z","updated_at":"2025-04-04T13:31:22.330Z","avatar_url":"https://github.com/dataplat.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Invoke-SqlCmd2\n==============\n\nInvoke-SqlCmd2 is a compact function to query SQL Server without other dependencies.  It was originally written by Chad Miller, with numerous community contributions along the way.\n\nThere are several key benefits to using Invoke-SqlCmd2:\n\n* Lightweight.  No installation needed; just copy or download the file, copy the text, `Install-Module`, etc.\n* Simple parameterized queries.  This was a source of exasperation in [2005](https://blog.codinghorror.com/give-me-parameterized-sql-or-give-me-death/).  Over a decade later, Invoke-SqlCmd is still missing this.\n* [Abstraction](https://powershell.org/2015/08/16/abstraction-and-configuration-data/).  Consider using and contributing to this, over writing your own .NET System.Data.SqlClient wrapper, or leaving a bunch of less friendly .NET code in your project\n\nPull requests and other contributions would be welcome!\n\n## Instructions\n\n```powershell\n# One time setup\n    # Download the repository\n    # Unblock the zip\n    # Extract the Invoke-SqlCmd2 folder to a module path (e.g. $env:USERPROFILE\\Documents\\WindowsPowerShell\\Modules\\)\n\n    # Simple alternative, if you have PowerShell 5, or the PowerShellGet module:\n        Install-Module Invoke-SqlCmd2\n\n# Import the module.\n    Import-Module Invoke-SqlCmd2    #Alternatively, Import-Module \\\\Path\\To\\Invoke-SqlCmd2\n\n# Get help\n    Get-Help Invoke-SqlCmd2 -Full\n```\n\n## Features\n\nProps to Chad Miller and the other contributors for a fantastic function.  We've added a few features with much help from others:\n\n* Added pipeline support, with the option to append a ServerInstance column to keep track of your results:\n  * ![Add ServerInstance column](/Media/ISCAppendServerInstance.png)\n* Added the option to pass in a PSCredential instead of a plaintext password\n  * ![Use PSCredential](/Media/ISCCreds.png)\n* Added PSObject output type to allow comparisons without odd [System.DBNull]::Value behavior:\n  * Previously, many PowerShell comparisons resulted in errors:\n    * ![GT Comparison Errors](/Media/ISCCompareGT.png)\n  * With PSObject output, comparisons behave as expected:\n    * ![GT Comparison Fix](/Media/ISCCompareGTFix.png)\n  * Previously, testing for nonnull / null values did not work as expected:\n    * ![NotNull Fails](/Media/ISCCompareNotNull.png)\n  * With PSObject output, null values are excluded as expected\n    * ![NotNull Fails Fix](/Media/ISCCompareNotNullFix.png)\n  * Speed comparison between DataRow and PSObject output with 1854 rows, 84 columns:\n    * ![Speed PSObject v Datarow](/Media/ISCPSObjectVsDatarow.png)\n\n### That DBNull behavior is strange!  Why doesn't it behave as expected?\n\nI agree.  PowerShell does a lot of work under the covers to provide behavior a non-developer might expect.  From my perspective, PowerShell should handle [System.DBNull]::Value like it does Null.  Please vote up [this Microsoft Connect suggestion](https://connect.microsoft.com/PowerShell/feedback/details/830412/provide-expected-comparison-handling-for-dbnull) if you agree!\n\nMajor thanks to [Dave Wyatt](http://powershell.org/wp/forums/topic/dealing-with-dbnull/) for providing the C# code that produces the PSObject output type as a workaround for this.\n\n### Why is Invoke-Sqlcmd2 here?\n\n* @RamblingCookieMonster copied the code [here](https://github.com/RamblingCookieMonster/PowerShell) to avoid the automated tweets for Poshcode.org submissions.  He makes many small changes and didn't want to spam twitter : )\n* Since then, a number of contributions have come in.  Separating this out into it's own repository simplifies and enables improved collaboration\n* Leaving this out of a larger module may be helpful for folks who simply want a lightweight function.  Modules can depend on this or hard code a point-in-time copy as needed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplat%2Finvoke-sqlcmd2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataplat%2Finvoke-sqlcmd2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataplat%2Finvoke-sqlcmd2/lists"}