My First Page
A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform ...
On this blog , I am posting about C# & Sql Queries and its programmes.Its Help To Improve Your Programming Skills...
A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform ...
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS
----Decimal to ASCIISELECT CHAR(80)+CHAR(73)+CHAR(78)+CHAR(65)+CHAR(76) ASSQLAuthorityAuthor
GO
----ASCII to DecimalSELECT ASCII('P') AS SQLAuthorityAuthorUNION ALLSELECT ASCII('I')UNION ALLSELECT ASCII('N')UNION ALLSELECT ASCII('A')UNION ALLSELECT ASCII('L')GO
DECLARE @YEAR SMALLINTSET @YEAR=2000SELECT @YEAR AS YEAR,CASE
DAY(EOMONTH(DATEADD(DAY,31,DATEADD(YEAR,@YEAR-1900,0))))WHEN 29 THEN 'YES' ELSE 'NO'END AS LEAP_YEAR
GO
YEAR LEAP_YEAR ------ --------- 2000 YES
SELECT
'CREATE INDEX IX_Auto_'
+
CONVERT
(
varchar
(
max
), MID.index_handle) +
' ON '
+
[statement] +
' ('
+
COALESCE
(equality_columns +
', '
+ inequality_columns, equality_columns, inequality_columns) +
')'
+
ISNULL
(
' INCLUDE ('
+ included_columns +
')'
,
''
)
AS
create_statement,
CONVERT
(
int
, avg_total_user_cost * user_seeks * avg_user_impact)
AS
potential_saving,
[statement]
AS
table_name,
equality_columns,
inequality_columns,
included_columns,
last_user_seek,
avg_total_user_cost,
user_seeks,
avg_user_impact
FROM
sys.dm_db_missing_index_details MID
JOIN
sys.dm_db_missing_index_groups MIG
ON
MIG.index_handle = MID.index_handle
JOIN
sys.dm_db_missing_index_group_stats MIGS
on
MIGS.group_handle = MIG.index_group_handle
ORDER
BY
avg_total_user_cost * user_seeks * avg_user_impact
DESC
Column | Description |
---|---|
create_statement | A SQL statement to create the proposed index. |
potential_saving | The relative query cost saving of this index. |
table_name | The fully qualified name of the table that the index applies to. |
equality_columns | Comma-separated list of columns that contribute to equality predicates of the form table.column = constant_value. |
inequality_columns | Comma-separated list of columns that contribute to inequality predicates, for example, predicates of the form table.column > constant_value. |
included_columns | Comma-separated list of columns needed as covering columns for the query. These are columns that aren’t used as key columns for the index, but are included for quick retrieval by queries. |
user_seeks | Number of seeks caused by user queries that the index could have been used for. |
last_user_seek | Date and time of last seek caused by user queries that the index could have been used for. |
avg_total_user_cost | Average cost of the user queries that could be reduced by the index. |
avg_user_impact | Average percentage benefit that user queries could experience if this index was implemented. The value means that the query cost would on average drop by this percentage if this index was implemented. |