Difference Between PowerShell and Shell Scripting – PART2

This blog is the continuation of my previous Blog, where I have explained the difference between PowerShell and Shell Scripting through 5 different scenarios. Here , in this Blog , I will take 5 more different commands and will show the difference between them.Consider one file in windows and one file in Linux with same Data. Clear the content of a fileWindows use “Clear-Content”Clear-Content .\PowerShell_Scripting.txt Linux uses “>” symbol to truncate or removing content of a file.>Linuxfile.txt Copy a file from one Location to anotherWindows uses “Copy-Item” command to remove…

Remove trailing spaces and zero from a string in SQL-Server

In this blog, I will discuss about “How to remove trailing spaces and zeros from a string without using any trim function”.I have written a procedure for the same. In one of my blog where I have shared the code for removing the leading zeros and spaces, here as well, code is almost the same. CREATE PROCEDURE [dbo].[RmTrailingZerosSpcs] (@String VARCHAR(500) )asBEGINDECLARE @output VARCHAR(100) = ”;DECLARE @prev CHAR(1) = ”;DECLARE @c CHAR(1) = ”;DECLARE @i int = 1;DECLARE @len int;DECLARE @len_zeros int =0;declare @reversestring varchar(200)select @reversestring= reverse(@String)SET @len = len(@reversestring);WHILE(@i <=…

Remove Leading Zeros and Spaces In SQL-SERVER

In this Blog, I will discuss about “How to remove Leading Zeros and Spaces from a value in SQL server”. I have written procedure for it . See the below code . CREATE PROCEDURE [dbo].[RmLeadZerosSpcs] (@String VARCHAR(500) )asBEGINDECLARE @output VARCHAR(100) = ”;DECLARE @prev CHAR(1) = ”;DECLARE @c CHAR(1) = ”;DECLARE @i int = 1;DECLARE @len int;DECLARE @len_zeros int =0;SET @len = len(@String);WHILE(@i <= @len) begin SET @c = SUBSTRING(@String, @i, 1); IF @c=’0′ or @c=’ ‘ BEGIN SET @len_zeros=len(@c)+@i SET @output = substring(@String,@len_zeros, @len); SET @i = @i + 1;…

Difference between Unix and PowerShell Commands

In this Blog, I will demonstrate the difference between Unix and PowerShell Commands. It will help all coders who works on Scripting Languages.Consider the one file in windows and one file in Linux with same data.See the below Image for the same. Find the Total Number of Records in a file . Linux uses “cat” and “wc -l” commandcat LinuxScripting.txt | wc -l Windows “Get-Content” and “Measure-Object” command. $File_count=Get-Content PowerShell_Scripting.txt |Measure-Object Read first n lines of a file Linux uses “cat” and “head” command.cat LinuxScripting.txt | head -3 Windows uses…

ORACLE INTERVIEW QUESTIONS

In this blog, I gathered few Interview Questions asked on Oracle Database. It will be very useful for 2-4 years of Experience IT Professionals.1. When we should use Materialized view and non materialized view.2. Difference between Ref cursor and sys ref cursor.3. What are the different types of TRIGGERS.4. Difference between SUBSTRING and INSTRING function.5. If a query is taking more time to display results, What’s first step will you perform to check this issue.6. Exceptional handling in Oracle procedure.7. Name PSEUDO columns in Oracle.8. Difference between Schema and User…

Examples of Awk Command

In this blog, I will explain various situations where you can use AWK command.Scenario 1: Identify the occurrence of a particular delimiter present in a variable.For example , consider a variable v_dem=”v1|100|v2|200|v3|300″Use Awk command , you can easily find the occurrence of Pipe delimiter in v_dem variable. Here, NF stands for Number of fields . LINUX COMMAND : echo $v_dem |awk -F ‘|’ ‘{print NF} ‘ Scenario 2: Print the values separated by Delimiter(Pipe in this case) using AWK command.LINUX COMMAND : echo $v_dem | awk -F “|” ‘ {for…

Check existence and non-existence of columns in a table

In this Bog, We will prepare a query which will tell us which tables has one specific column but another column which is also important is not present.QUERY-1select distinct TABLE_NAME from INFORMATION_SCHEMA.COLUMNS c where COLUMN_NAME=’column1′ and not exists ( select 1 from INFORMATION_SCHEMA.columns cc where cc.TABLE_NAME=c.TABLE_NAMEand cc.COLUMN_NAME=’column2′) The above Query will list all tables in which column1 is present and column2 is not present. QUERY-2select distinct TABLE_NAME from INFORMATION_SCHEMA.COLUMNS c where COLUMN_NAME=’column1′ and exists ( select 1 from INFORMATION_SCHEMA.columns cc where cc.TABLE_NAME=c.TABLE_NAMEand cc.COLUMN_NAME=’column2′) This Query will list all tables in…

get all Values separated by delimiter in sql

In this blog, I will discuss about “How to get all values separated by delimiter in SQL”. In one of my previous blog, where I have explained about positions of all delimiters present in a string. We will use same logic here as well. For example I have string with value abc@gmail.com;xyz@gmail.com;123@gmail,comIn the above string, I have three email ids which are separated by delimiter ; . I need these values in below format abc@gmail.comxyz@gmail.com123@gmail,com Use the below code to fetch the data in above format . declare @var1 varchar(100)…

Delete data from Access Database in Pentaho

In this Blog, I am going to discuss about “How to delete data from Access Database using Pentaho ETL tool”. In order to understand how to setup Access Database connection in Pentaho, you can use this link for the same.In order to delete data from Access table, consider a table Table1 in a Access Database (Access_Sample_DB.accdb) having two rows . Follow below steps in order to delete record from Table1 Access table.Open Pentaho workspace using spoon.batOpen New TransformationCreate Access Database Connection as per the above link.Drag Execute SQL Script component.Run…

select Query using Access database in Pentaho

In this Blog, I will discuss about ” How to Query the access database tables in Pentaho”. In my previous blog, where I have explained how to create Access database connection in Pentaho. Please go through this blog to have better understanding on Access database in Pentaho. I created one sample table(Table1) in Access database(Access_Sample_DB.accdb) and inserted two records. See the below SS. Open Pentaho using spoon.bat . Open New Transformation and drag “Table Input” Component and select the Access Database Connection. Write the simple select Query to fetch records…