{"id":20774461,"url":"https://github.com/segovoni/sp_drop_create_stats_external_table","last_synced_at":"2025-10-26T07:03:28.682Z","repository":{"id":209329798,"uuid":"723438432","full_name":"segovoni/sp_drop_create_stats_external_table","owner":"segovoni","description":"Generate all the T-SQL statements for drop and create statistics defined on SQL Server external tables in your database!","archived":false,"fork":false,"pushed_at":"2023-11-26T17:53:05.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-18T07:44:36.007Z","etag":null,"topics":["polybase","sql-server","statistics","stored-procedure","utility"],"latest_commit_sha":null,"homepage":"","language":"TSQL","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/segovoni.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":"2023-11-25T17:06:29.000Z","updated_at":"2023-11-26T17:50:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"22b0473b-1be3-468f-8af9-401b374f565a","html_url":"https://github.com/segovoni/sp_drop_create_stats_external_table","commit_stats":null,"previous_names":["segovoni/sp_drop_create_stats_external_table"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segovoni%2Fsp_drop_create_stats_external_table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segovoni%2Fsp_drop_create_stats_external_table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segovoni%2Fsp_drop_create_stats_external_table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/segovoni%2Fsp_drop_create_stats_external_table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/segovoni","download_url":"https://codeload.github.com/segovoni/sp_drop_create_stats_external_table/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243112190,"owners_count":20238182,"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":["polybase","sql-server","statistics","stored-procedure","utility"],"created_at":"2024-11-17T12:29:37.728Z","updated_at":"2025-10-26T07:03:28.578Z","avatar_url":"https://github.com/segovoni.png","language":"TSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sp_drop_create_stats_external_table\n\nThe `sp_drop_create_stats_external_table` is able to generate all the T-SQL statements for drop and create statistics defined on SQL Server external tables in your database!\n\nThe [CREATE STATISTICS](https://learn.microsoft.com/sql/t-sql/statements/create-statistics-transact-sql?WT.mc_id=DP-MVP-4029181#limitations-and-restrictions) documentation page says: \"Updating statistics is not supported on external tables. To update statistics on an external table, drop and re-create the statistics\". SQL Server documentation tells us explicitly that update statistics is not supported on external tables!\n\nWhen creating external table statistics, SQL Server imports the external table into a temporary SQL Server table and then creates the statistics. For sample statistics, only the sampled rows are imported. If you have a large external table, it is faster to use the default sampling instead of the full scan option.\nIn addition, when the external table uses `DELIMITEDTEXT`, `CSV`, `PARQUET`, or `DELTA` as data types, external tables only support statistics for one column per `CREATE STATISTICS` command.\n\nThe error can be worked around using one of the following options:\n\n- Ignore the external table (this option is not available for maintenance plan managed by SQL Server Management Studio maintenance plan; third-party solutions are needed)\n- Drop and create statistics as a part of the maintenance plan (drop statistics before starting the update statistics task and recreate them after the statistics maintenance)\n\nI loved the second option, so I developed the stored procedure `sp_drop_create_stats_external_table` that can generate all the T-SQL statements for drop and create statistics defined on external tables; it supports statistics on multiple columns.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegovoni%2Fsp_drop_create_stats_external_table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsegovoni%2Fsp_drop_create_stats_external_table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsegovoni%2Fsp_drop_create_stats_external_table/lists"}