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
echo "$Query"
, maybe? Always quote your variables. – AlexP Jan 10 '20 at 09:27*
in your query. Does your question title actually reflect the question being asked? – Chris Davies Jan 10 '20 at 10:21