I use SAP B1 at work and want to export a CSV file in a batch file so that I can schedule the export every 15 minutes to be uploaded to a website.
This is what I have at the moment:
SQLCMD -S SERVER-VMSQL -d SBO_COMPANYNAME -U sa -P adminpassword -Q "SELECT ItemCode, FrgnName, OnHand-IsCommited FROM OITM" -s "," -o "\\server-address\users\rick\TestBat.csv" -h-1 -s"," -W -w 999
This gives me an export of a CSV with the columns:
- Item Code
- Item Name
- Qty on hand less qty on sales orders
What I need is to elaborate on this query to put in some WHERE clauses - for example WHERE:
- U_Category = 'Toys' (where U_Category is a user defined field)
- Qrygroup2 = 'Y'
All of the above fields are within the OITM table.
Also - how do you join tables with SQLCMD queries? I need to be able to join the OITW table to be able to specify in the WHERE clause that T1.[WhsCode] = '01. Main'.
Any help would be greatly appreciated!
Regards Rick