Posts

Showing posts from August, 2018

log_reuse_wait_desc showing as REPLICATION but replication is not configured.

Image
One day i got an alert saying as Transaction log file of a particular database has been increasing. I check the following things to troubleshoot the issued. 1) Database recovery model is in SIMPLE 2) log_reuse_wait_desc showing as REPLICATION but there is no replication at all in that server. This means there might be database restore happens from replication configured database 3)I try to find out is there any open transactions are running on the server and found there is a open transaction like below. WorkAround: 1)  Run the below command in the respective database. EXEC sp_repldone null, null, 0 , 0 , 1 2) Run CHECKPOINT after that as database is already in Simple Recovery model 3) Now run DBCC OPENTRAN and see you will not find any open transactions at this moment 4) Now you can shrink the log file by using DBCC SHRINKFILE command.

How to access another server info from the present server by using power shell command

The below query will provide you the other server information from this server by using power shell command. This is like getting remote server information from this server. Invoke-Command ` -ComputerName ProvideServerNamehere ` -ScriptBlock { Get-EventLog -LogName Application | Where-Object { $_ . Message -like "*failed to open*" } | Where-Object { $_ . TimeWritten -like "*08/29/2018*" } | Format-List } ` -Credential Provide User Name Here without single quotes

Importing blob to the local Virtual Machine C drive by using Azcopy

Image
First we need to download AzCopy tool for windows in the virtual machine. You can use below link to do that. https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy After you installing it it will create some files in the below format. Then open command prompt from run and run the below command. By using the "cd" change the path name as mentioned below. The highlighted script written below gives you the syntax and the key value i have taken from below image and provide the same as value  for the 'Destkey' parameter.
By using AzurePowershell command we can create Azure StorageAccount,Container and we can upload BLOB to Azure. New-AzureRmStorageAccount  ` -ResourceGroupName   20533D0101-LabRG  ` -Name   "bookch4pss"  ` -Location   "eastus"  ` -SkuName   Standard_LRS  ` -Kind   Storage #Get teh key of StorageAccount $mystorekey = ( Get-AzureRmStorageAccountKey  ` -ResourceGroupName   20533D0101-LabRG  ` -Name   $StorageAccountName ) $mystorekey . value #Variable declarations for StorageAccountName and StorageAccountKey $StorageAccountName = "bookch4pss" $StorageAccountKey = "Provide the second value from above $mystorekey" #Definig storage account context using storage account name $ctx = New-AzureStorageContext  ` -StorageAccountName   $StorageAccountName  ` -StorageAccountKey   $StorageAccountKey #Need to create a value and name to the container $ContainerN...

WORKING WITH PAGE RESTORE OPTION IN SQL SERVER

Image
USE page go CREATE TABLE recipes (   recipe_id INT   NOT NULL,   recipe_name VARCHAR ( 30 ) NOT NULL,   PRIMARY KEY ( recipe_id ),   UNIQUE ( recipe_name ) ); INSERT INTO recipes ( recipe_id , recipe_name ) VALUES ( 1 , 'Tacos' ), ( 2 , 'Tomato Soup' ), ( 3 , 'Grilled Cheese' ), ( 4 , 'Tomatoes' ), ( 5 , 'A' ), ( 6 , 'B' ), ( 7 , 'C' ), ( 8 , 'D' ), ( 9 , 'E' ) go GO /*  Take the backup of Page database after you creating a table. */ USE master go BACKUP DATABASE Page TO DISK = 'D:\Mirror\Page_Full_08232017.BAK' WITH STATS = 10 /*  The below query will provided the indexes that are there in the recipes table */ USE PAGE GO SELECT object_name ( object_id ),* FROM sys . indexes WHERE   object_name ( object_id )= 'recipes' GO /* Enable below traceflag to show you ful information of index page a...