MSSQL Query Blog

Log File Shrinking in SQL Server

Hello everyone, In this article, I will try to give information about shrinking the log file in SQL Server. In SQL Server, in some cases you may want to shrink the log file. You can easily do this using the code below. USE DatabaseName –You will write the database name...

Viewing Database Restore History in SQL Server

Hello everyone, In this article, I will try to give information about viewing database restore history in SQL Server. In SQL Server, you may want to view the database restore history in some cases. You can easily do this using the code below. SELECT [restore_date] ,[destination_database_name] ,[user_name] ,[backup_set_id] ,[restore_type] ,[replace]...

Creating a New GUID in SQL Server

Hello everyone, In this article, I will try to give information about creating a new GUID in SQL Server. In SQL Server you may want to create a new GUID in some cases. You can easily do this by using the sample code below. SELECT NEWID() When you create and...

Seeing Backup or Restore Progress in SQL Server

Hello everyone, In this article, I will try to give information about seeing the backup or restore progress in SQL Server. In SQL Server, in some cases you may want to see the backup or restore progress. You can easily do this using the code below. SELECT session_id AS SPID,...

Decrypting Base64 Encrypted Data in SQL Server

Hello everyone, In this article, I will try to give information about decoding Base64 encrypted data in SQL Server. In SQL Server, in some cases, you may want to decrypt Base64 encrypted data. You can easily do this using the code below. SELECT CONVERT ( VARCHAR(MAX), CAST(” AS XML).value(‘xs:base64Binary(sql:column(“BASE64_COLUMN”))’, ‘VARBINARY(MAX)’)...

Listing Weekends of Selected Years in SQL Server

Hello everyone, In this article, I will try to give information about listing the weekends of selected years in SQL Server. In SQL Server, in some cases you may want to list the weekends of selected years. You can easily do this using the code below. DECLARE @startDate DATETIME, @endDate...

Listing All Time Between Two Dates in SQL Server

Hello everyone, In this article, I will try to give information about listing all the times of the day between two dates in SQL Server. In SQL Server, in some cases you may want to list all the times between two dates. You can easily do this using the code...

Don`t copy text!