MSSQL Query Blog

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;...

Capturing High Resource Queries in SQL Server

Hello everyone, In this article, I will try to give information about capturing high resource queries in SQL Server. In SQL Server, in some cases, you may want to capture your high resource queries. You can easily do this using the code below. SELECT TOP 10 SUBSTRING( qt.text, (qs.statement_start_offset /...

Getting Next Identity Value in SQL Server

Hello everyone, In this article, I will try to give information about getting the next Identity value in SQL Server. In SQL Server, in some cases you may want to get the next Identity value. You can easily do this using the code below. SELECT IDENT_CURRENT(‘Categories’) + IDENT_INCR(‘Categories’) AS Identity_Sonraki_Deger;...

Searching for a View on a Database in SQL Server

Hello everyone, In this article, I will try to give information about searching for View on the database in SQL Server. In SQL Server, in some cases, you may want to call View on the database. You can easily do this using the code below. DECLARE @Views TABLE (ViewName NVARCHAR(4000))...

Validating Date in SQL Server

Hello everyone, In this article, I will try to give information about validating dates in SQL Server. In SQL Server, in some cases, you may want to know that the entered date is a valid date. Namely; The date 31092022 (a date expression without a period in between) normally does...

Don`t copy text!