 Hey guys, welcome to SSUnitex, so see this side and this is continuation of SQL Server project. So in the last video we have seen how we can check the login credentials. So the data in the table is encrypted. So we have seen how we can check the first time login for the user and after that we have checked for the login details. So today we are going to check if user is going to login the first time then it will ask to change the password. So how we can write the SP and that SP will be going to help us for update the password in the table. So go to on the SQL server and we will try to create that SP. So here as we can see we are having this login details table. So in this table we are having business entity ID login ID then login has value. So this is the encrypted value then we are having the password that is also encrypted and we are having the flag. So basically the flag is going to indicate this user did not login any time. So once it will be going to login, so this password will be going to update and this flag value should be update. So we need to write the SP. So how we can write that? So basically it will be going to have two input parameters. So let me call this SP as SPROC update password and it will be going to have two parameters. So first parameter will be login ID and this is where care 100 and then the password. So this password again will be where care 100. Then we can put this as then we can have this begin and in between we need to write the code. So first what we need to check. So we need to check if your new password is same as existing password. Then we need to reflect the flag value as 0. If your new password is not the same password then you need to update that. So first let me declare a variable declare at the rate flag and this would be integer and by default we can put this as 0. So here what we can do we can check if exist select one then from our table that is login details where we need to check for the login ID. So here we have login ID at value and here we can check for the password equals to. So it is having at the rate login ID which will be the input parameter and for the password it is also having the input parameter. So either we can decrypt this or we can encrypt this. So let me try to decrypt this. So if you have remember how we can do the decrypt. So we can use the decrypt by pass pass. Then we need to specify the hash key value and after that this login ID. So if you have remember the hash key value is ssunitech. So it seems good but we need to do the cast cast this value as where care max. The same thing that we need to do for the password as well. So we can use the decrypt by pass pass and here we can specify ssunitech and then put comma then after this put the bracket as where care and it should be max. And here we can use the cast. So here if the existing password is the new password then we need to return inside the flag. We can have the flag value. So at the red flag we can set on this as 0. So which is the by default value and then we can use the go to option with ssu and below of that we can have ssu like this. So this is if this is not the case if your new password is not the same one. So what we need to do so on that scenario we need to do the update statement. So we can use the update set and where cross in the update we can have the login details and in the where cross it should be going to have the login ID hash value is equals to login ID like this. So for this either we can directly copy this code from here and try to put it here we need to update the password. So equals to add the rate password but we need to do the encrypt on this password. So what we can do we can use the encrypt by pass pass then we need to specify the hash value that is ssunited and after that we can close the bracket. Second we need to update the flag value. So this flag value is equals to flag value plus 1 but before going to update this we need to check the null on this flag if that is null then we can use the 0. We can remove this and below of this ssu we can select this flag value. So select add the rate flag as status. So what it means basically if we are going to check this flag value if that value is 0 so we can have this as 1. So by default it is 1 if we are going to see if the existing value is same as new value then we are going to set this as 0 otherwise it is 1. So by this flag value we could see the status inside the API if we are getting 1 so it means the data is updated successfully if we are getting 0 it means the existing value is the same one which is the new value. So that we can directly return in the API so user can directly see and after that they can update the password after making little bit modification on the password. So this SP will be going to help us on this scenario. So I hope guys you have understand how we can create this update password SP. So thank you so much for watching this video if you like this video please subscribe our channel to get many more videos and if you need this SP so I will try to put this on the description of this video so you can directly copy from there. See you in the next video with new project.