-1

Linux, Bash Script.

I have created a query as below, which works

sqlcmd -S [dbname].database.windows.net -d [database name]-U [username ]-P [password] -Q "SELECT * FROM dbo.microiopenvpn WHERE mode='create'"

How do I then loop over results.

The table has name, email_address & mode fields.

I just want the email_address field (for this query)

James_Inger
  • 83
  • 2
  • 10

1 Answers1

0

Figured it out - one way I guess

while IFS="," read -r d1 d2 d3 d4 d5 d6; do
   echo "$d1" "$d2" "$d4"

done < sqloutputNew.csv

Get the column from each row, then iterates, seems to be the best solution I could find.

With the SQL having an output as below

-o "sqloutputNew.csv" -W -w 1024 -s"," -h-1
James_Inger
  • 83
  • 2
  • 10