TSQL – AumTechHub.Com http://aumtechhub.com Just share it!!! Tue, 23 Nov 2021 01:57:25 +0000 en-US hourly 1 https://wordpress.org/?v=6.7 179596041 SSRS Report Run History http://aumtechhub.com/ssrs-report-run-history/?utm_source=rss&utm_medium=rss&utm_campaign=ssrs-report-run-history Thu, 27 Aug 2020 02:29:10 +0000 http://aumtechhub.com/?p=46 The following query shows report history for a report name (Employee Attendance Report) in the WHERE clause. This is a great way to check what parameters are used and how often the report is being called.

select
[InstanceName]
, [ReportPath]
, [UserName]
, [ExecutionId]
, [RequestType]
, [Format]
, [Parameters]
, [ReportAction]
, [TimeStart]
, [TimeEnd]
, [TimeDataRetrieval]
, [TimeProcessing]
, [TimeRendering]
, [Source]
, [Status]
, [ByteCount]
, [RowCount]
, [AdditionalInfo]
FROM ExecutionLog2
Where ReportPath like '% Employee Attendance Report %'
Order by TimeStart desc

]]>
46
Rename Database By closing connections http://aumtechhub.com/rename-database-by-closing-connections/?utm_source=rss&utm_medium=rss&utm_campaign=rename-database-by-closing-connections Tue, 25 Aug 2020 02:49:39 +0000 http://aumtechhub.com/?p=19 When trying to rename database with open database connections its always a pain as the admin has to kill those connections. Instead of going that route one can use the following code.

USE [master]
GO
ALTER DATABASE NameOfYourDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE NameOfYourDatabase
Modify Name = NewNameOfYourDatabase
GO
ALTER DATABASE NewNameOfYourDatabase SET MULTI_USER;

Note: Name of the database in the query above is case sensitive.

]]>
19
How to read registry entries for SQL? http://aumtechhub.com/how-to-read-registry-entries-for-sql/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-read-registry-entries-for-sql Tue, 25 Aug 2020 00:43:16 +0000 http://aumtechhub.com/?p=14 Following query shows all the registry values on the server.

select
[registry_key]
,[value_name]
,[value_data]
from [sys].[dm_server_registry]

]]>
14
How to get SQL Service details? http://aumtechhub.com/how-to-get-sql-service-details/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-get-sql-service-details Tue, 25 Aug 2020 00:39:32 +0000 http://aumtechhub.com/?p=12 Run the following query under context of any system or user database to get the sql server database engine account and the account for sql server agent.

select
[servicename]
,[startup_type]
,[startup_type_desc]
,[status]
,[status_desc]
,[process_id]
,[last_startup_time]
,[service_account]
,[filename]
,[is_clustered]
,[cluster_nodename]
from [sys].[dm_server_services]

]]>
12
How to tell when data changed in a table? http://aumtechhub.com/how-to-tell-when-data-changed-in-a-table/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-tell-when-data-changed-in-a-table Tue, 25 Aug 2020 00:30:17 +0000 http://aumtechhub.com/?p=10 This query will show list of each table when it was last scanned

SELECT
OBJECT_NAME(OBJECT_ID) AS TableName
,[database_id]
,[object_id]
,[index_id]
,[user_seeks]
,[user_scans]
,[user_lookups]
,[user_updates]
,[last_user_seek]
,[last_user_scan]
,[last_user_lookup]
,[last_user_update]
,[system_seeks]
,[system_scans]
,[system_lookups]
,[system_updates]
,[last_system_seek]
,[last_system_scan]
,[last_system_lookup]
,[last_system_update]
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( 'NameOfDatabase')​

Note: Replace the ‘NameOfDatabase‘ with the name of your database. Also be sure run the query in the context of the same database.

]]>
10