Thursday, July 9, 2020

Looking for password to your router in windows 10


Hi,
How often have you forgotten the password to your router. I know it is not save to keep in a text file. So what I do is to keep them in keypass  You can use keypass to generate and store passswords for your home/organization. Well now coming back to today's topic. How to view the old password stored in Windows10. 

Now for checking the existing password for your router to which you are connected. As in you need to connect to that network router. 

For powerusers -> you can type ncpa.cpl and go to step for wifi adapter settings directly. 

Once done click on the wifi icon again in the tool bar.  



Then go to the network and internet settings option. 


Then choose the wifi in the left hand side of the screen. 



Then go to the right hand side of the screen and choose Change Adapter Options. 


Then go to the wifi adapter setting and click on status. 


Then click on the wireless properties. 


Then go to the security tab and click on show characters. 



There you go Bam.. you have the password you were looking for. 

Remember this only works in Windows 10 and not in Mac or Linux. You need to be careful while changing passwords else you will have to reset the router which will drain all your settings. 



Thanks,
Tushar 




Wednesday, July 8, 2020

How to increase typing speed

Hi,
I have been facing a lot of issues with my typing off late and thought I will key in my personal experience to help anyone else who might be facing the same issue.

Well to begin with I was never required to type so much other than a couple of adhoc scripts for automation where my typing speed was not judged. But off late I have changed my career path to that of a developer and now I need to type a lot and almost in a regular fashion. This caused me realise that I could not type very fast when I am not looking. And it is impossible to type looking at the keyboard unless you are typing something in English that does not have to deal with any line of code. And yes I agree most season coders do not need to look up while they are typing. But hey I just said I have changed my career path I never said I have marveled at it.

Well then here are my realisations which may help someone to improve their speed and make less mistakes while typing.  I am taking about more than 40 words per minute of typing.

1. I understood that the keystrokes I did was based on my experience and not the actual knowledge of the keys. So that's they real key (pun intended) . You need to wire  your brain to the actual position of the keys. You can actually improve your accuracy by typing a little slow. If I want to type at 30 words per minute I will make less mistakes and hence improve in accuracy but who wants to get slow in this fast age.
2. The keyboard itself. The keyboard may be doing you more harm than you can possibly think of. The layout and the design of the keys matter a lot. If I am writing something in Mac or Surface I make 10-20% less mistakes the keyboard is very smooth and welcoming for me to type but some keyboard like lenovo V330 series can be a real pain. The Lenovo X1 has a much better keyboard and to work with. So do not beat yourself up if you are making a lot of mistakes while typing it might be a good time to upgrade your laptop/dekstop/keyboard.
3. Auto correction does fix a lot of issues and you tend to ignore it but it surfaces when you are writing a tech code and you have a intellisence included client to work on but still make more mistakes than you expect it is because you always had been making those mistakes but the autocorrect was fixing them fast enough for you to ignore.
4. The key stroke mistakes that I do are off by just one or two keystrokes and then it occurred to me that it is a lack of discipline. The keys have to be assigned a left and a right hand and they need to be used with only that hand. The error in keystroke happens only when I used the wrong hand. For instance I have trained my left hand to press g but if I use my right hand then I am bound to make a mistake.
5. When we are coding we might be working on multiple screens and this may cause us to look at right or left while writing a code and that makes us think the keyboard is also a little oriented in that direction and that can cause us to move our hands a little further than we normally do. This can be fixed by keeping the screens really close to each other.


Well these are some of the basic things I felt are making my life more miserable than I thought it would. All said if you just practice for 5 minutes on a daily basis to type looking at the keyboard and then 5 minutes looking at the screen it will help you in the long way. And you will see improvements almost immediately.

Let me know what you think on my findings and let me know if it helped you.

Thanks,
Tushar Kanti

Calculating Monthly Balance for GLAccounts using BSEG

Hi ,
I have been working a lot with SAP related systems both ECC and CRM. Just wanted to tell you that it was a real nightmare when I started my journey almost an year back in 2019. So the SAP Systems have all the table and column names based in German. The is an organization called Simplement which adds a lot of helpful texts in English which help us to understand what the table/column actually means. Trust me it helps a lot to keep the sanity in place when you just start off. But later on once you get the hang of it you will remember the most important tables like VBAK, VBRK , BSEG , BKPF on top of your head. These tables are very broad and have multiple column names which sound similar and have similar data and sometimes it makes no sense to plain eyes why so many similar columns are required. But SAP treats or uses each column for a specific purpose and has these columns populated so it have less agrregations or calculations done on the fly.

Well to being with today's article/blog. I want to tell you what BSEG actually is and how you can do a balance for all GLAccounts for a company. Now BSEG is Accounting Document Segment and BKPF is Accounting Document Header
Here goes the complicated yet beautiful query.

SELECT h.[BUKRS: (PK) Company Code],s.[HKONT: General Ledger Account],h.[GJAHR: (PK) Fiscal Year], MONTH( h.[BUDAT: Posting Date in the Document]) PostingMonth,
  SUM(  CASE WHEN s.[SHKZG: Debit/Credit Indicator]='H' THEN s.[DMBE2: Amount in Second Local Currency]*-1 ELSE s.[DMBE2: Amount in Second Local Currency] END )
 GLAMountUSD 
FROM LIB_ECP_RTP.bv.[BSEG: Accounting Document Segment] s WITH (nolock)
JOIN LIB_ECP_RTP.bv.[BKPF: Accounting Document Header] h WITH (nolock) ON h.[BELNR: (PK) Accounting Document Number]=s.[BELNR: (PK) Accounting Document Number]
AND h.[BUKRS: (PK) Company Code] = s.[BUKRS: (PK) Company Code] AND h.[GJAHR: (PK) Fiscal Year] = s.[GJAHR: (PK) Fiscal Year]
AND MONTH(h.[BUDAT_SIMP_DT: (GC) Posting Date in the Document]) = h.[MONAT: Fiscal Period]
AND h.[MANDT: (PK) Client] = s.[MANDT: (PK) Client]
WHERE 1=1
AND h.[BUKRS: (PK) Company Code]='YourCompany'
AND h.[GJAHR: (PK) Fiscal Year]='2020'
AND s.[VORGN: Transaction Type for General Ledger]<>'RFIG'
AND s.[UMSKZ: Special G/L Indicator] NOT IN ('F','A')
GROUP BY  MONTH(h.[BUDAT: Posting Date in the Document]), h.[BUKRS: (PK) Company Code], s.[HKONT: General Ledger Account], h.[GJAHR: (PK) Fiscal Year]
ORDER BY h.[BUKRS: (PK) Company Code], s.[HKONT: General Ledger Account], h.[GJAHR: (PK) Fiscal Year] ,MONTH(h.[BUDAT: Posting Date in the Document])


Now we are using the BUKRS as the first column which is nothing but the name of the company. The next is the GLAccount which is what you actually what to see the balance monthly for. 
The GJAHR is the Actual year ; here we have filtered by 2020.
Next is BUDAT which is the data and we are taking the month from that, which is the line item we want to see for the balance. 
Next is GLAMountUSD which is the sum of the amount with a case for the debit and credit indicator. So when it's H it is to be mutipolied by  -1 so it is reversed as the amount column is not signed. 

There you so you have the monthly balance in a very condensed form. 

Thanks,
Tushar Kanti 











Monday, April 6, 2020

Restoring multiple databases via script

Hi Guys,
Hope you are having fun with SQL as usual.
I have developed a script which I thought may be useful to the community least they need to restore huge number of databases from backups without using any enteprise restore software.

Script is broken into two major parts
1. Getting the names of the databases that needs to be restored.
2. Getting the restore script for the databases in question

Now let's delve into the Scripts.
1. Names of the Databases 
Here in this example I am restoring the databases in offline mode. Just a scenario we can use this to be any scenario.

DECLARE @db_row INT
SELECT @db_row=COUNT(name) FROM sys.databases where state_desc<>'online';
DECLARE @res_script varchar(max)

SELECT TOP (@db_row) b.database_name,physical_device_name,b.type,b.backup_start_date
INTO #backup_tab
FROM msdb..backupset b
join msdb..backupmediafamily f on f.media_set_id=b.media_set_id and type ='d'
AND database_name IN (select name from sys.databases where state_desc<>'online')
order by b.backup_start_date DESC

Now we have the information of the backup set of the databases in question. Now let's move on to the next part of the query.

2. Restore Script
Here we use a cursor. I personally do not like them but for this time I thought it will be easy to use a cursor. I will try in future to write it without a cursor.

DECLARE @dbname sysname, @backpath nvarchar(260)
DECLARE rest_cur CURSOR FOR
SELECT database_name FROM #backup_tab ORDER BY 1

OPEN rest_cur
FETCH NEXT FROM rest_cur INTO @dbname
WHILE @@FETCH_STATUS=0
BEGIN
SELECT @backpath=physical_device_name FROM #backup_tab WHERE database_name=@dbname
SELECT @res_script=''

SELECT @res_script= 'RESTORE database [' + @dbname + '] from disk ='+'''' + @backpath+''''

SELECT  @res_script=@res_script+ ' WITH '

SELECT @res_script=@res_script+' move '''+name+''' ' + 'to ''' +physical_name+''','
FROM sys.master_files
WHERE 1=1
AND database_id=DB_ID(@dbname)

SELECT @res_script=@res_script+ 'stats=1 ,replace'

print @res_script
--EXEC(@res_script)
FETCH NEXT FROM rest_cur INTO @dbname

END
CLOSE rest_cur
DEALLOCATE rest_cur

DROP TABLE #backup_tab

It's one of my hot favourite scripts in a disaster recovery scenario. Hope you guys liked it.

Here is the link to the script file


Thanks,
Tushar

Recovering Master Database with Master and Data log file

Hi ,
There are times when you will need to fix a corrupt database server and you will need to restore your master database from a good old backup.  This situation is fairly documented and does not need further elaboration with so many articles floating around from God's of SQL Server to help us. 

But I found another situation which was new and different from the other situations. 
I will start with giving you the configuration path so it will help to imagine the pain and progress. 

OS Installation - C:\ Drive 
SQL Installation - D:\ Drive 
SQL User and Data Log file - E:\ Drive (I know please do not shout it's our dev and I did not build it)
SQL Backup - J:\ Drive

SQL Server version - SQL Server 2016 upgraded from SQL Server 2012. 

Ok now that we have base line set let me show you the scenario. 

The OS crashed aka C drive and the backup crashed aka J:\ Drive. 

So we had to get the OS rebuilt to get something up and running. 
SQL was definitely not up because the OS had no clue there was any installation. 

So we had a discussion with the Infra Team that they will install SQL 2012 and then upgrade 2016 and bring it up to the same patch level as before the disaster and then we will try and re-attach the old system database files to bring up the system.

But as I have mentioned before things do not get fixed so easily once they are messed up in DB World. Specially when some one is blogging about it. 

So when I got back the system I saw that the super smart Infra Guy had installed 2016 with the latest patch directly rather than the upgrade path and he improvised on choosing the new path for the system databases to be E:\ drive rather than the default D:\ Drive and he was very proud that he had fixed a glitch with the original install plan. 


Only if he could understand my pain but let me help you understand by elaborating a little on this. 

1. The old system database files were in D Drive when the disaster happened so if we put them in the new path and start the server it will not come up with the missing address link from old (in master database ) to new path . 
2. If we put the old system databases in the old path and try to start the SQL Server then the resource database will happen address issues. 

So I devised an interim plan to first modify all the existing system databases to old database file path in D:\ Drive so the resource database will be updated. Second we will shutdown the database server and attach the old database files to bring up the system. 

Well after attaching the old database files and restarting the SQL Server the System resumed and all the databases and other objects came online. 

This is how we potentially avoided the need to redo all the login , packages and jobs from prod to dev and saved weeks of development effort. 


Thanks,
Tushar Kanti