Guest User

Untitled

a guest
Apr 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. select log_reuse_wait_desc from sys.databases where name = 'tempdb'
  2.  
  3. #0AF29B96
  4. #0B5CAFEA
  5. #0BE6BFCF
  6. #0C50D423
  7.  
  8. SELECT SUM(unallocated_extent_page_count) AS [free pages],
  9. (SUM(unallocated_extent_page_count)*1.0/128) AS [free space in MB],
  10. SUM(internal_object_reserved_page_count) AS [internal object pages used],
  11. (SUM(internal_object_reserved_page_count)*1.0/128) AS [internal object space in MB],
  12. SUM(user_object_reserved_page_count) AS [user object pages used],
  13. (SUM(user_object_reserved_page_count)*1.0/128) AS [user object space in MB]
  14. FROM sys.dm_db_file_space_usage;
  15.  
  16. SELECT SUM(size)*1.0/128 AS [size in MB]
  17. FROM tempdb.sys.database_files
  18.  
  19. free pages free space in MB internal object pages used internal object space in MB user object pages used user object space in MB
  20. ------------ ----------------- -------------------------- ---------------------------- ---------------------- -----------------------
  21. 1829424 14292.375000 320 2.500000 80 0.625000
  22.  
  23. size in MB
  24. -------------
  25. 22490.062500
  26.  
  27. SELECT t1.name AS [Service_Name], t3.name AS [Schema_Name], t2.name AS [Queue_Name],
  28. CASE WHEN t4.state IS NULL THEN 'Not available'
  29. ELSE t4.state
  30. END AS [Queue_State],
  31. CASE WHEN t4.tasks_waiting IS NULL THEN '--'
  32. ELSE CONVERT(VARCHAR, t4.tasks_waiting)
  33. END AS tasks_waiting,
  34. CASE WHEN t4.last_activated_time IS NULL THEN '--'
  35. ELSE CONVERT(varchar, t4.last_activated_time)
  36. END AS last_activated_time ,
  37. CASE WHEN t4.last_empty_rowset_time IS NULL THEN '--'
  38. ELSE CONVERT(varchar,t4.last_empty_rowset_time)
  39. END AS last_empty_rowset_time,
  40. (
  41. SELECT COUNT(*)
  42. FROM sys.transmission_queue t6
  43. WHERE (t6.from_service_name = t1.name)
  44. ) AS [Tran_Message_Count]
  45. FROM sys.services t1
  46. INNER JOIN sys.service_queues t2
  47. ON ( t1.service_queue_id = t2.object_id )
  48. INNER JOIN sys.schemas t3
  49. ON ( t2.schema_id = t3.schema_id )
  50. LEFT OUTER JOIN sys.dm_broker_queue_monitors t4
  51. ON ( t2.object_id = t4.queue_id AND t4.database_id = DB_ID() )
  52. INNER JOIN sys.databases t5
  53. ON ( t5.database_id = DB_ID() )
  54.  
  55. Service_Name Schema_Name Queue_Name Queue_State tasks_waiting last_activated_time last_empty_rowset_time Tran_Message_Count
  56. ------------------------------------------------------------------------- ------------ ----------------------------- --------------- -------------- -------------------- ----------------------- -------------------
  57. InternalMailService dbo InternalMailQueue INACTIVE 0 Apr 7 2013 8:10AM Apr 7 2013 8:10AM 0
  58. ExternalMailService dbo ExternalMailQueue INACTIVE 0 Apr 7 2013 8:10AM Apr 7 2013 8:10AM 0
  59. http://schemas.microsoft.com/SQL/Notifications/QueryNotificationService dbo QueryNotificationErrorsQueue Not available -- -- -- 0
  60. http://schemas.microsoft.com/SQL/Notifications/EventNotificationService dbo EventNotificationErrorsQueue Not available -- -- -- 0
  61. http://schemas.microsoft.com/SQL/ServiceBroker/ServiceBroker dbo ServiceBrokerQueue Not available -- -- -- 0
  62.  
  63. SELECT OBJECT_NAME(id), rowcnt
  64. FROM tempdb..sysindexes
  65. WHERE OBJECT_NAME(id) LIKE '#%'
  66. ORDER BY rowcnt DESC
  67.  
  68.  
  69. SELECT
  70. SUM (user_object_reserved_page_count)*8 as usr_obj_kb,
  71. SUM (internal_object_reserved_page_count)*8 as internal_obj_kb,
  72. SUM (version_store_reserved_page_count)*8 as version_store_kb,
  73. SUM (unallocated_extent_page_count)*8 as freespace_kb,
  74. SUM (mixed_extent_page_count)*8 as mixedextent_kb,
  75. SUM (User_object_reserved_page_count +
  76. internal_object_reserved_page_count +
  77. version_store_reserved_page_count +
  78. unallocated_extent_page_count +
  79. mixed_extent_page_count) * 8 as total_space
  80. FROM sys.dm_db_file_space_usage
  81.  
  82. USE [tempdb]
  83. GO
  84. DBCC FREEPROCCACHE -- this will free up all cache plans
  85. GO
  86. USE [tempdb]
  87. GO
  88. DBCC SHRINKFILE (N'tempdev' , 10000) -- will shrink the mdf file to 10GB, you can specify log file as well
  89. GO
Add Comment
Please, Sign In to add comment