Tag: "t-sql"

Which service pack do I have installed?

Related to previous post's, sometimes it is helpful to quickly determine SQL Server's service pack level.By selecting @@VERSION in a query window ...SELECT @@VERSION AS "SQL Server Version"you / I get following result: more »

Checking the running time since last SQL-Server instance startup

Below script will query sys.dm_exec_sessions to find out how long the SQL-Server instance is running. CodeDECLARE @elapsed_time AS DATETIME, @lr_start_time AS DATETIME SELECT @lr_start_time = (SELECT last_request_start_time FROM sys.dm_exec_sessions… more »

Which login has what server role permissions

Below script will query sys.server_role_members / sys.server_principals to find out which logins have what server role access. CodeSELECT 'ServerRole' = CASEWHEN rm.role_principal_id > 2 THEN SUSER_NAME(rm.role_principal_id) END,lgn.name AS… more »

Blocking per object with sys.dm_db_index_operational_stats

SELECT DB_NAME(database_id) AS 'DB_NAME', QUOTENAME(OBJECT_SCHEMA_NAME(ios.[object_id], database_id)) + N'.' + QUOTENAME(OBJECT_NAME(ios.[object_id], database_id)) AS 'OBJECT_NAME', i.name AS 'INDEX_NAME', i.index_id AS 'INDEX_ID',… more »
1 2