Sqoop not exporting all the records

hive

#1

I am exporting the data from hive table to SQLServer table, but at times all the records do not get exported.
I have a plan to solve this issue by writing a shell script that

  1. Stores the count of hive table in a variable.
  2. Stores the count of SQL Server table in another variable.
  3. Compares the value of the two variables,
    if var1 != var 2
    {
    Delete the rows in SQL Server Server;
    Rerun my sqoop script
    }
    else
    exit;

Question: How to store the count of rows of a hive table in a variable in a shell script?
How to store the count of rows of a table in SQL-Server-Management studio in a shell script?