0

I have table in database which stores few queries, Using sqlcmd I am trying to retrieve the queries. While doing so, the select * from abc is getting replaced with 'select from abc'

How to overcome this issue?

Edit:

Max_Values=5
n=1
while [ $n -le $Max_Values ]
do
Sql_Qry="set nocount on;Select Query from dbo.abc With(nolock) Where RowID=$n"  

Query=`/opt/mssql-tools/bin/sqlcmd -S Server_name -U UserID -P Password -d database -Q "$Sql_Qry" -h -1`
echo $Query
n=$(( n+1 ))
done

Expected Output:

Select * from Int.Table1

Actual Output:

Select Script1.txt script2.sh script3.sh from Int.Table1

The script1, script2 and script3 are files within the current directory

jesse_b
  • 37,005
Venkat
  • 3

1 Answers1

0

Double quote the variable that you want to print will fix the problem. i.e.

echo "$Query"

Paulo Tomé
  • 3,782
kokei
  • 69