{"id":15002523,"url":"https://github.com/madeiradata/fileoperationsclr","last_synced_at":"2026-03-11T08:01:50.544Z","repository":{"id":250606121,"uuid":"834926614","full_name":"MadeiraData/FileOperationsCLR","owner":"MadeiraData","description":"SQL-CLR project for running file operations from within a SQL Server instance without needing xp_cmdshell","archived":false,"fork":false,"pushed_at":"2024-09-03T16:54:16.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T02:38:26.561Z","etag":null,"topics":["bcp","microsoft-sql-server","mssql","mssqlserver","sql-clr","sqlclr","sqlserver"],"latest_commit_sha":null,"homepage":"https://www.madeiradata.com","language":"C#","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/MadeiraData.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-07-28T18:24:55.000Z","updated_at":"2024-09-03T16:54:21.000Z","dependencies_parsed_at":"2024-09-24T18:50:56.374Z","dependency_job_id":"f79243ae-34f5-402a-bffc-6c9a238e1c92","html_url":"https://github.com/MadeiraData/FileOperationsCLR","commit_stats":null,"previous_names":["madeiradata/runbcp","madeiradata/fileoperationsclr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MadeiraData/FileOperationsCLR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadeiraData%2FFileOperationsCLR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadeiraData%2FFileOperationsCLR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadeiraData%2FFileOperationsCLR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadeiraData%2FFileOperationsCLR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MadeiraData","download_url":"https://codeload.github.com/MadeiraData/FileOperationsCLR/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MadeiraData%2FFileOperationsCLR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30375465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bcp","microsoft-sql-server","mssql","mssqlserver","sql-clr","sqlclr","sqlserver"],"created_at":"2024-09-24T18:51:00.046Z","updated_at":"2026-03-11T08:01:50.518Z","avatar_url":"https://github.com/MadeiraData.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RunBCP\n\n**APPLIES TO:** ![Yes](media/yes-icon.png)SQL Server ![No](media/no-icon.png)Azure SQL Database ![No](media/no-icon.png)Azure SQL Managed Instance ![No](media/no-icon.png)Azure Synapse Analytics (SQL DW) ![No](media/no-icon.png)Parallel Data Warehouse \n\nSQL-CLR project for running the [BCP utility](https://learn.microsoft.com/en-us/sql/tools/bcp-utility) from within a SQL Server instance without needing [xp_cmdshell](https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/xp-cmdshell-transact-sql).\n\nCredit to Marcin from [this Stack Overflow thread](https://stackoverflow.com/questions/36397427/what-is-the-best-to-remove-xp-cmdshell-calls-from-t-sql-code) for the original code.\n\n## Example\n\n```sql\n/* Example usage: */\n\nUSE [myTestDB]\nGO\n\nDECLARE @arguments nvarchar(max) = 'myTestDB.dbo.OrderDetails out \"C:\\temp\\OrderDetails.bcp\" -T -c -C ACP'\nDECLARE @output_msg nvarchar(max)\nDECLARE @error_msg nvarchar(max)\nDECLARE @return_val int\n\nEXECUTE [dbo].[RunBCP] \n   @arguments\n  ,@output_msg OUTPUT\n  ,@error_msg OUTPUT\n  ,@return_val OUTPUT\n\nSELECT\n @output_msg\n,@error_msg \n,@return_val\n```\n\n\n## Installation\n\n**More detailed instructions TBA**\n\nBefore being able to import this SQL-CLR into your database, you need to import its digital signing key.\n\nYou can use a script such as below to do this (remember to enable SQLCMD mode):\n\n```sql\n/* Remove the \"setvar\" lines below unless you want to run this script manually */\n:setvar PathToSignedDLL C:\\Madeira\\RunBCP.dll\n:setvar CLRKeyName RunBCPAssemblyKey\n:setvar CLRLoginName RunBCPAssemblyLogin\n:setvar DatabaseName myTestDB\n/*\n Pre-Deployment Script Template\tFor Importing a Signed CLR Assembly (SSDT Project)\n--------------------------------------------------------------------------------------\nIn order to use this script, you must configure the following SQLCMD Variables in your project:\n\n$(PathToSignedDLL)\n$(CLRKeyName)\n$(CLRLoginName)\n\nTo configure your SQLCMD Variables: Right-click on your DB project, select \"Properties\", and go to \"SQLCMD Variables\".\nAdd your new SQLCMD Variables in the grid.\n\nThe $(PathToSignedDLL) variable is particularly tricky, because it requires you to know, in advance,\nthe path to your signed assembly DLL. That file may not be available until after you first build your project.\nConsistent file paths must be maintained, especially when using CI/CD pipelines.\n\nTo sign your assembly:\nRight-click on your DB project, select \"Properties\", and go to \"SQLCLR\".\nClick on the \"Signing...\" button.\nEnable the \"Sign the assembly\" checkbox.\nUsing the dropdown box, choose an existing strong name key file (*.snk) or create a new one.\nSet a password for the key file.\nThis password is required for this phase only (initial signing config).\nIf you plan to use the same strong name key file for other assemblies, make sure to save your password.\n--------------------------------------------------------------------------------------\n*/\n-- Make sure clr is enabled\nIF EXISTS (select * from sys.configurations where name IN ('clr enabled') and value_in_use = 0)\nBEGIN\n\tDECLARE @InitAdvanced INT;\n\tSELECT @InitAdvanced = CONVERT(int, value) FROM sys.configurations WHERE name = 'show advanced options';\n\n\tIF @InitAdvanced = 0\n\tBEGIN\n\t\tEXEC sp_configure 'show advanced options', 1;\n\t\tRECONFIGURE;\n\tEND\n\n\tEXEC sp_configure 'clr enabled', 1;\n\tRECONFIGURE;\n\n\tIF @InitAdvanced = 0\n\tBEGIN\n\t\tEXEC sp_configure 'show advanced options', 0;\n\t\tRECONFIGURE;\n\tEND\nEND\nGO\n-- Database context must be switched to [master] when creating the key and login\nuse [master];\nGO\n-- Create asymmetric key from DLL\nIF NOT EXISTS (SELECT * FROM master.sys.asymmetric_keys WHERE name = '$(CLRKeyName)')\n\tCREATE ASYMMETRIC KEY [$(CLRKeyName)]\n\tFROM EXECUTABLE FILE = '$(PathToSignedDLL)'\nGO\n-- Create server login from asymmetric key\nIF NOT EXISTS (SELECT name FROM master.sys.syslogins WHERE name = '$(CLRLoginName)')\n\tCREATE LOGIN [$(CLRLoginName)] FROM ASYMMETRIC KEY [$(CLRKeyName)];\nGO\n-- Grant UNSAFE/EXTERNAL_ACCESS/SAFE ASSEMBLY permissions to login which was created from DLL signing key\nGRANT UNSAFE ASSEMBLY TO [$(CLRLoginName)];\nGO\n-- Return execution context to intended target database\nUSE [$(DatabaseName)];\nGO\n```\n\n## License\n\nAll materials in this repository are released under the [MIT license](https://github.com/MadeiraData/RunBCP/blob/master/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeiradata%2Ffileoperationsclr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadeiradata%2Ffileoperationsclr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadeiradata%2Ffileoperationsclr/lists"}