Masking Relationship Keys in SQL Server

USE [UserManagement]
GO/****** Object: Table [dbo].[MaskLookup] Script Date: 2/28/2019 11:54:47 AM ******/
DROP TABLE [dbo].[MaskLookup]
GO/****** Object: Table [dbo].[MaskLookup] Script Date: 2/28/2019 11:54:47 AM ******/
SET ANSI_NULLS ON
GOSET QUOTED_IDENTIFIER ON
GOCREATE TABLE [dbo].[MaskLookup](
[oldvalue] [char](1) NULL,
[newvalue] [char](3) NULL
) ON [PRIMARY]
GO

 


alter FUNCTION dbo.fnMaskValues(@input nvarchar(1000))
RETURNS nvarchar(1000)
AS
BEGIN
declare @output as varchar(1000) =”– Choose the appropriate size
declare @currentValue as char(1)
declare @i int
select @i = 0
while @i < len(@input)
begin
set @i = @i + 1
set @currentValue = Lower(substring(@input, @i, 1))
if EXISTS (select 1 from MaskLookup where oldvalue=@currentValue)
select @output=@output+ RTRIM(LTRIM(newvalue)) from MaskLookup where Lower(oldvalue)=@currentValue;
else
select @output=@output+@currentValue;

end
RETURN @output;
END;

Clearing Messages in Rabbit MQ

In Testing Environment , many messages are getting accumulated due to various reasons. There is an option in the Rabbit MQ to purge the messages manually, this job will get tougher and time consuming if there more number of queues. In my there were around 500 queues with 1000 messages in each.

I used the below commands to clear messages in all the queues . After executing these commands we need  reconfigure the RabbitMQ, and it was done using the poweshell scripts in my case. These commands needs to be executed from the RabbitMQ installation directory inside sbin folder

Commands :

  1. rabbitmqctl stop_app
  2. rabbitmqctl reset
  3. rabbitmqctl start_app

 

Powershell scripts to manage windows services

Below are powershell scripts to perform Start , Stop and Get Status of the windows services remotely

“Start” the Service :
Get-Service -Name servicename -ComputerName machine1,machine2 | Set-Service -Status Running
“Stop” the Service
Get-Service -Name servicename -ComputerName machine1,machine2 | Set-Service -Status Stopped
“Status” of the Service
Get-Service -Name servicename -ComputerName machine1,machine2 Continue reading “Powershell scripts to manage windows services”