This discussion assumes a database Recovery Model of “Full,” which is the normal recommendation for production databases. This setting allows the backup of the transaction log so that you can recover up to the point of failure by restoring log backups in order. A Recovery Model of “Simple” will automatically truncate the transaction log periodically, but you are not allowed to backup the log in this mode, so you can only recover using the last database backup, which implies potential loss of transactions. This setting is usually reserved for test or read-only databases.
Backing up the transaction log will not only backup the latest committed transactions within the log but will also truncate the log file. Truncation means that the transactions that were backed up are removed from the log file, freeing up space within the log file for new transactions. The truth is, if you don’t backup the transaction log, it will continue to grow forever, until you run out of disk space.
New DBAs to SQL Server assume that the Full Database Backup truncates the transaction log – it doesn’t. It does take a snapshot of the transaction log at the very end, so that transactions committed during a long-running full backup are actually backed up, too (which is quite clever), but it does not truncate the log. Well, the long-term solution is to backup the transaction log frequently. This will keep the transaction log “lean and mean.” But how frequent is frequent? Well, it depends. Generally, we try to keep the transaction log under 50% of the size of the data files. If it grows beyond this, then we back it up more frequently. This is why, for some very active databases, we may backup the log every 15 minutes. As I said, it depends.
This article provides several ways to identify the TCP/IP port number used by SQL Server.
Find the Running Port Number through Query
The following query provides a direct answer about TCP/IP port used by the SQL Server, as well as the SQL Server’s IP address.
SELECT DISTINCT local_net_address, local_tcp_port
WHERE local_net_address IS NOT NULL;
Find the Running Port Number through xp_readerrorlog
The command xp_readerrorlog read the SQL Server logs, which consists of SQL Server boot log, to find the SQL Server listening port through keywords in the boot log.
xp_readerrorlog 0, 1, N'Server is listening on'
Get the Running Port from the TCP/IP Properties
- Open the SQL Server Configuration Manager
- In the SQL Server Configuration Manager, under the SQL Server Network Configuration, select your SQL Server instance.
- After that, right click on TCP/IP and select Properties. You will find the SQL Server running port on the following screen.
A simple explanation on how log shipping works could be “Backup-Transfer-Restore”. Transaction log will backup on the primary database and transfer the log backup file to the secondary database server, eventually restore it to the database. Thus, any changes on the primary database will reflect on the secondary database.
How to trouble shoot when the log shipping failed and the below error message found in the job history?
Could not find a log backup file that could be applied to secondary database '<DATABASE_NAME>'.
This means the current log backup file which being restored is too recent. A backup from a prior time need to be applied first. Since the log being backed up in sequence on the primary server, the log need to restore according to the sequence as well on the secondary database.
Use the following query to check when is the last log backup file that was copied:
SELECT * FROM [msdb].[dbo].[log_shipping_secondary]
And, also check what was the last log backup file was restore.
SELECT * FROM [msdb].[dbo].[log_shipping_secondary_databases]
Sometime larger transaction log file may takes longer time to copy over to the secondary server while the newer file already copied over, thus it looks unsorted on the secondary database. So wait for the big file to be copied and restart the log shipping job again. Second case, you may need to check the retention time on backup job that run on primary server.
If you see the file on primary server that was not yet copied, you may need to manually copy that over and then start the log shipping again. If the file is not there, you may need to reconfigure the log shipping process again. You can refer to this site on how to configure log shipping for your database.
This one will list all online databases on the server and the last modified date
DECLARE @sqlString NVARCHAR(max)
DECLARE @union NVARCHAR(max)
SET @sqlString = ''
SET @union = ''
DECLARE @name nvarchar(50);
DECLARE crs CURSOR FOR
SELECT Name FROM sys.databases WHERE state = 0
FETCH NEXT FROM crs INTO @name
WHILE @@FETCH_STATUS = 0
SET @sqlString = @sqlString + @union
SET @sqlString = @sqlString + '
''' + @name + ''' as DBName, modify_date
[' + @name + '].sys.tables'
SET @union = ' UNION '
FETCH NEXT FROM crs INTO @name
SET @sqlString = @sqlString + ' ORDER BY DBName ASC'
Thanks for the sharing from @Adam_Jorgensen about the new features and capabilities in SQL Server 2008 R2. The image below is a sample of the videos available at Microsoft SQL Server Tour Videos. Visit to the site to learn more about SQL Server 2008 R2 today!