Skip to content

Instantly share code, notes, and snippets.

View uricken1964's full-sized avatar

Uwe Ricken uricken1964

View GitHub Profile
@uricken1964
uricken1964 / get_statistics_columns_info.sql
Created December 30, 2024 10:15
The given T-SQL code defines a function dbo.get_statistics_columns_info that returns a table with information about statistics and their associated columns for a specified object in a database.
CREATE OR ALTER FUNCTION dbo.get_statistics_columns_info
(
@object_name NVARCHAR(128),
@object_type NVARCHAR(10)
)
RETURNS TABLE
AS
RETURN
(
SELECT TOP 100 PERCENT
@uricken1964
uricken1964 / get_statistics_update_info.sql
Last active December 30, 2024 10:11
This UDF returns the threshold for all statistics when these statistics are automatically updated. Parameters: @object_schema: NULL or name of the object schema @object_name: NULL or the name of the table object @tf2371_enabled: 0 or 1 for new threshold calculation before SQL 2016
CREATE OR ALTER FUNCTION dbo.statistics_update
(
@object_id INT,
@stats_id INT,
@tf2371_enabled BIT = 1
)
RETURNS TABLE
AS
RETURN
(