MSSQL Query Blog

Seeing Table Sizes in SQL Server

Hello everyone, In this article, I will try to give information about seeing table sizes in SQL Server. In SQL Server you may want to see table sizes in some cases. You can easily do this using the code below. SELECT t.name AS TableName, s.name AS SchemaName, p.rows AS RowCounts,...

Updating Statistics with Cursor in SQL Server

Hello everyone, In this article, I will try to give information about updating Statistics with Cursor in SQL Server. Although Statistics are updated automatically in SQL Server, sometimes they need to be updated manually. You can easily do this using the code below. DECLARE @sql NVARCHAR(500); DECLARE @tableName NVARCHAR(200); DECLARE...

Viewing Job History in SQL Server

Hello everyone, In this article, I will try to give information about viewing Job history in SQL Server. In SQL Server, in some cases, you may want to learn the working status of Jobs, that is, their history. You can easily do this using the code below. SELECT [job].[job_id] AS...

Check Index Fragmentation on All Indexes in SQL Server

Hello everyone, In this article, I will try to give information about fragmentation detection in all Indexes in SQL Server. In SQL Server you may want to see fragmentation on all Indexes. You can do this easily using the code below. SELECT dbschemas.[name] AS ‘Schema’, dbtables.[name] AS ‘TABLE’, dbindexes.[name] AS...

Writing a WordWrap Function in SQL Server

Hello everyone, In this article, I will try to give information about writing a WordWrap function in SQL Server. In SQL Server you may need a function like WordWrap in some cases. WordWrap cuts a text to a certain length and displays the remainder on a new line. This is...

CPU Usage Information in SQL Server

Hello everyone, In this article, I will try to give information about CPU usage information in SQL Server. In SQL Server, you may want to see CPU usage information in some cases. You can easily do this using the code below. DECLARE @ms_ticks_now BIGINT; SELECT @ms_ticks_now = ms_ticks FROM sys.dm_os_sys_info;...

Don`t copy text!