Friday, May 21, 2021

How to Enable or Disable Fast User Switching in Windows PC

Fast User Switching is an easy way for another person to log on to the computer without logging you off or closing your programs and files. Follow the steps below to for Fast Switch User.

1. To begin, make sure that you have logged in as Administrator or have required administrative rights to change local group policies.

2. Press the Windows +R button.

3. Run dialog box will pop-up,type gpedit.msc. This will open Local Group Policy Editor. (see pic 1 for reference)

4. Now, go to the following location and look for Local Computer Policy in the left pane.

5. Click on Local Computer Policy/Computer Configuration/Administrative Templates/System/Logon. (See Pic 2 for refrence)

6. Just double-click Hide Entry Points for Fast User Switching to bring up a dialog box to change Fast User Switching policy setting.

7. At the top, there are Not Configured, Enabled and Disabled options available. Selecting each setting will let you read its affect in Help section. To disable Hide Entry Points for Fast User Switching, just select Enabled from the list and click OK.

If you need to diable this option, you need to select Disabled from the list. Rest all process is same.

8. Once done, you will have to enforce this change made to Fast User Switching policy setting. To do so, close the Local Group Policy Editor and open the Run dialog box (Windows +R button). Enter the command “gpupdate /force“ and click OK. The policy will be updated and applied on all user accounts.

9. To re-enable Fast User Switching, just choose Not Configured in its policy setting dialog and apply the changes via gpupdate /force command.

Hope this helps setting up mutiple users to login on your PC.

Monday, April 19, 2021

How to get only numbers from string sql

I have column where I need to get only numbers form the string.

Here is how we can do,

SUBSTRING(columnName, PATINDEX('%[0-9]%', columnName), LEN(columnName))

Here's the example with PATINDEX

use databasego
-- inventory Group, Employee , cost center
select [Cost Center], [Inventory Group], Employee, 
SUBSTRING(Employee, PATINDEX('%[0-9]%', Employee), LEN(Employee)) AS EmployeeID
from  tmp_BulkOrder_SP_4_16_21

Hope this helps 😀

Sunday, March 21, 2021

How to remove special characters from a string using a function with RegEx

Here is how you can get remove special characters from a string in SQL

-- SELECT dbo.[RemoveCharSpecialSymbolValue] ('naga3fg@#sai') 
CREATE FUNCTION [dbo].[RemoveCharSpecialSymbolValue](@str VARCHAR(500))  
RETURNS VARCHAR(500)  
BEGIN  
DECLARE @startingIndex int  
SET @startingIndex=0  
WHILE 1=1  
	BEGIN  
	SET @startingIndex= patindex('%[^0-9a-zA-Z]%',@str)  
	IF @startingIndex <> 0  
		BEGIN  
			SET @str = replace(@str,substring(@str,@startingIndex,1),'')  
		END  
	ELSE BREAK;  
END  
RETURN @str  
END   

Hope this helps 😀

Saturday, March 20, 2021

How to remove alpha numeric characters from a string using function with RegEx

Here is how you can get alpha numeric characters from a string in SQL

-- SELECT dbo.[RemoveCharSpecialSymbolIntValue] ('naga3@#sai') 
CREATE FUNCTION [dbo].[RemoveCharSpecialSymbolIntValue](@str VARCHAR(500))  
RETURNS VARCHAR(500)  
BEGIN  
DECLARE @startingIndex int  
SET @startingIndex=0  
	WHILE 1=1  
	BEGIN  
		SET @startingIndex= patindex('%[^0-9.]%',@str)  
		IF @startingIndex <> 0  
		BEGIN  
			SET @str = replace(@str,substring(@str,@startingIndex,1),'')  
		END  
		ELSE BREAK;  
	END  
	RETURN @str  
END 

Hope this helps 😀

Sunday, February 07, 2021

How to remove ASCII Characters from a string using function

Here is how you can remove ASCII characters from a string in SQL

CREATE FUNCTION [dbo].RemoveASCIICharactersInRange(@InputString VARCHAR(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
    IF @InputString IS NOT NULL
    BEGIN
      DECLARE @Counter INT, @TestString NVARCHAR(40)

      SET @TestString = '%[' + NCHAR(0) + NCHAR(1) + NCHAR(2) + NCHAR(3) 
      + NCHAR(4) + NCHAR(5) + NCHAR(6) + NCHAR(7) + NCHAR(8) + NCHAR(11) 
      + NCHAR(12) + NCHAR(14) + NCHAR(15) + NCHAR(16) + NCHAR(17) 
      + NCHAR(18) + NCHAR(19) + NCHAR(20) + NCHAR(21) + NCHAR(22) 
      + NCHAR(23) + NCHAR(24) + NCHAR(25) + NCHAR(26) + NCHAR(27) 
      + NCHAR(28) + NCHAR(29) + NCHAR(30) + NCHAR(31) 
      + NCHAR(127)+ NCHAR(160)+ ']%'

      SELECT @Counter = PATINDEX (@TestString, @InputString COLLATE Latin1_General_BIN)

      WHILE @Counter <> 0
      BEGIN
        SELECT @InputString = STUFF(@InputString, @Counter, 1, '')
        SELECT @Counter = PATINDEX (@TestString, @InputString COLLATE Latin1_General_BIN)
      END
    END
    RETURN(@InputString)
END

Hope this helps 😀