{"id":7744135,"name":"snsinahub/sqlcmd","ecosystem":"actions","description":"An action for running Invoke-SqlCmd in Windows powershell","homepage":"https://github.com/marketplace/actions/sqlcmd-powershell","licenses":"apache-2.0","normalized_licenses":["Apache-2.0"],"repository_url":"https://github.com/snsinahub/sqlcmd","keywords_array":["actions","apache-2","apache-license-2","open-source","opensource","powershell","sql","sql-server","sqlcmd-powershell"],"namespace":"snsinahub","versions_count":4,"first_release_published_at":"2022-06-16T21:56:02.000Z","latest_release_published_at":"2022-06-29T14:10:59.000Z","latest_release_number":"v2.2.0","last_synced_at":"2026-05-13T23:18:01.475Z","created_at":"2023-05-17T08:45:55.383Z","updated_at":"2026-05-13T23:18:01.475Z","registry_url":"https://github.com/snsinahub/sqlcmd","install_command":null,"documentation_url":null,"metadata":{"name":"SQLCMD","description":"An action for running Invoke-SqlCmd in Windows powershell","author":"Siavash Namvar","branding":{"icon":"database","color":"gray-dark"},"inputs":{"sql_path":{"description":"sql_path","required":false},"server_name":{"description":"Server Name or IP address","required":true},"db_name":{"description":"db name","required":true},"sqlcmd_variables":{"description":"sqlcmd_variables","required":false,"default":""},"input_type":{"description":"sqlcmd_variables_type","required":false,"default":""},"query_timeout":{"description":"query_timeout","required":false,"default":""},"sqlcmd_action":{"description":"sqlcmd_action","required":true}},"outputs":{"random-number":{"description":"Random number","value":"${{ steps.random-number-generator.outputs.random-number }}"}},"runs":{"using":"composite","steps":[{"run":"echo \"sqlcmd scripts\"     \n\nif (!(Get-Module -ListAvailable -Name SqlServer)) \n{            \n    Write-Output \"Installing PowerShell module $Name for current user\"\n    Install-PackageProvider -Name NuGet -Force -Scope CurrentUser;\n    Install-Module -Name SqlServer -Force -AllowClobber -Scope CurrentUser -Repository PSGallery -SkipPublisherCheck;\n}\n\nif (-not (Get-Module -Name SqlServer)) \n{            \n    Import-Module -Name SqlServer -DisableNameChecking;\n}   \n\n## create invoke command\n$PS = \"Invoke-Sqlcmd -ServerInstance ${{ inputs.server_name }} -Database ${{ inputs.db_name }} -InputFile '${{ inputs.sql_path }}' -OutputSqlErrors 1 -ErrorAction Stop \"\n\n## set sqlcmd variables             \n[string]$variables = ${{ inputs.sqlcmd_variables }}\n$varArray = $(${{ inputs.sqlcmd_variables }})\n[string]$VARS = ''        \n$VARS = $variables.split(\" \")                      \n\n\n## set timeout time in seconds\n$TO = '${{ inputs.query_timeout }}'\n\n$i=0\nif ( $VARS -ne '' ) {\n  $PS += \" -Variable \"           \n  foreach ($item in $varArray) {      \n    if( $i -ne 0 )\n    {\n      $PS += ' ,\"' + $item + '\" '\n    }\n    else \n    {\n      $PS += ' \"' + $item.replace('\"', \"'\") + '\" '\n      $i++;\n    }                  \n    \n  }\n}\nelse\n{\n  echo \"variable empty\"\n}\n\nif ( $TO -ne '' ) {\n  $PS += \" -QueryTimeOut '${{ inputs.query_timeout }}'\"\n}\nelse\n{\n  echo \"TO empty\"\n}\n\n## Generate command\n$command = [Scriptblock]::Create($PS)\necho \"COMMAND --\u003e $command\"\nInvoke-Command -ScriptBlock $command\n","id":"sqlcmd-script","shell":"powershell","if":"${{ inputs.sqlcmd_action == 'script' \u0026\u0026 inputs.input_type != 'inline' }}"},{"run":"echo \"sqlcmd scripts inline\"     \n\nif (!(Get-Module -ListAvailable -Name SqlServer)) \n{            \n    Write-Output \"Installing PowerShell module $Name for current user\"\n    Install-PackageProvider -Name NuGet -Force -Scope CurrentUser;\n    Install-Module -Name SqlServer -Force -AllowClobber -Scope CurrentUser -Repository PSGallery -SkipPublisherCheck;\n}\n\nif (-not (Get-Module -Name SqlServer)) \n{            \n    Import-Module -Name SqlServer -DisableNameChecking;\n}   \n\n## create invoke command\n$PS = \"Invoke-Sqlcmd -ServerInstance ${{ inputs.server_name }} -Database ${{ inputs.db_name }} -InputFile '${{ inputs.sql_path }}' -OutputSqlErrors 1 -ErrorAction Stop \"\n\n## set sqlcmd variables             \n$variables = \"${{ inputs.sqlcmd_variables }}\" \n$varArray = $($variables.split(\" \"))\n[string]$VARS = ''        \n$VARS = $variables.split(\" \")                      \n\n\n## set timeout time in seconds\n$TO = '${{ inputs.query_timeout }}'\n\n$i=0\nif ( $VARS -ne '' ) {\n  $PS += \" -Variable \"           \n  foreach ($item in $varArray) {      \n    if( $i -ne 0 )\n    {\n      $PS += ' ,\"' + $item + '\" '\n    }\n    else \n    {\n      $PS += ' \"' + $item.replace('\"', \"'\") + '\" '\n      $i++;\n    }                  \n    \n  }\n}\nelse\n{\n  echo \"variable empty\"\n}\n\nif ( $TO -ne '' ) {\n  $PS += \" -QueryTimeOut '${{ inputs.query_timeout }}'\"\n}\nelse\n{\n  echo \"TO empty\"\n}\n\n## Generate command\n$command = [Scriptblock]::Create($PS)\necho \"COMMAND --\u003e $command\"\nInvoke-Command -ScriptBlock $command\n","id":"sqlcmd-script-inline","shell":"powershell","if":"${{ inputs.sqlcmd_action == 'script' \u0026\u0026 inputs.input_type == 'inline' }}"}]},"default_branch":"main","path":null},"repo_metadata":{"uuid":"503898865","full_name":"snsinahub/sqlcmd","owner":"snsinahub","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-29T14:12:00.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2023-07-13T08:41:46.202Z","etag":null,"topics":["actions","apache-2","apache-license-2","open-source","opensource","powershell","sql","sql-server","sqlcmd-powershell"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/sqlcmd-powershell","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snsinahub.png","metadata":{},"created_at":"2022-06-15T19:35:57.000Z","updated_at":"2022-08-09T02:05:15.000Z","dependencies_parsed_at":"2023-01-04T12:15:07.522Z","dependency_job_id":null,"html_url":"https://github.com/snsinahub/sqlcmd","commit_stats":null,"previous_names":[],"tags_count":4,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snsinahub","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":145457198,"owners_count":6248110,"icon_url":"https://github.com/github.png","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"},"owner_record":{"login":"snsinahub","name":"Siavash Namvar","uuid":"90400593","kind":"user","description":"Solution Architect at GitHub. Passionate about delivering solutions. Linux enthusiast.","email":"","website":null,"location":"United States","twitter":null,"company":"GitHub","icon_url":"https://avatars.githubusercontent.com/u/90400593?u=4223d09002ed09a6084045e544d011834fd3eedd\u0026v=4","repositories_count":7,"last_synced_at":"2023-03-05T20:33:47.016Z","metadata":{"has_sponsors_listing":false},"html_url":"https://github.com/snsinahub","created_at":"2022-11-15T22:25:29.544Z","updated_at":"2023-03-05T20:33:47.023Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snsinahub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snsinahub/repositories"},"tags":[{"name":"v2.2.0","sha":"5b63916679986f89d1d6e76188072c2c34f3fe39","kind":"commit","published_at":"2022-06-29T14:10:59.000Z","download_url":"https://codeload.github.com/snsinahub/sqlcmd/tar.gz/v2.2.0","html_url":"https://github.com/snsinahub/sqlcmd/releases/tag/v2.2.0","dependencies_parsed_at":"2023-05-31T02:08:05.555Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v2.2.0","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v2.2.0/manifests"},{"name":"v2.1.0","sha":"b25acbeef51c5869f5678e02ba80a124da1a3225","kind":"commit","published_at":"2022-06-29T14:06:32.000Z","download_url":"https://codeload.github.com/snsinahub/sqlcmd/tar.gz/v2.1.0","html_url":"https://github.com/snsinahub/sqlcmd/releases/tag/v2.1.0","dependencies_parsed_at":"2023-05-31T02:08:05.707Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v2.1.0","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v2.1.0/manifests"},{"name":"v2.0.0","sha":"1a932be10ef0d3868e6be27a8b9a7d586d4ebdb7","kind":"commit","published_at":"2022-06-27T19:45:10.000Z","download_url":"https://codeload.github.com/snsinahub/sqlcmd/tar.gz/v2.0.0","html_url":"https://github.com/snsinahub/sqlcmd/releases/tag/v2.0.0","dependencies_parsed_at":"2023-05-31T02:08:05.832Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v2.0.0","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v2.0.0/manifests"},{"name":"v1.0.0","sha":"adc184e02c0c27dd10d64032d1d953de521a4c5b","kind":"commit","published_at":"2022-06-16T21:56:02.000Z","download_url":"https://codeload.github.com/snsinahub/sqlcmd/tar.gz/v1.0.0","html_url":"https://github.com/snsinahub/sqlcmd/releases/tag/v1.0.0","dependencies_parsed_at":"2023-05-31T02:08:05.954Z","dependency_job_id":null,"tag_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v1.0.0","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snsinahub%2Fsqlcmd/tags/v1.0.0/manifests"}]},"repo_metadata_updated_at":"2023-07-13T08:41:56.615Z","dependent_packages_count":0,"downloads":null,"downloads_period":null,"dependent_repos_count":0,"rankings":{"downloads":null,"dependent_repos_count":40.26221692491061,"dependent_packages_count":0.0,"stargazers_count":48.81764060265407,"forks_count":35.22640316731543,"docker_downloads_count":null,"average":31.076565173720027},"purl":"pkg:githubactions/snsinahub/sqlcmd","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/actions/snsinahub/sqlcmd","docker_dependents_count":null,"docker_downloads_count":null,"usage_url":"https://repos.ecosyste.ms/usage/actions/snsinahub/sqlcmd","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/actions/snsinahub/sqlcmd/dependencies","status":null,"funding_links":[],"critical":null,"issue_metadata":null,"versions_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/snsinahub%2Fsqlcmd/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/snsinahub%2Fsqlcmd/version_numbers","latest_version_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/snsinahub%2Fsqlcmd/latest_version","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/snsinahub%2Fsqlcmd/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/snsinahub%2Fsqlcmd/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/github%20actions/packages/snsinahub%2Fsqlcmd/codemeta","maintainers":[]}