Starting off, I know VFP is terrible. However, due to many stipulations beyond my control I have to use VFP to execute all MSSQL queries.

So I am making a Visual Fox Pro application that will execute queries for those I don't want executing their own queries.

So we have a QueryType Variable, Editbox and a FromTable combo box. There are several of these running down the form for when you need to run more than one query at a time, the goal here is to Union them.

However, I am quite new to all Database queries and am having trouble making the Union part work.

This is all in a form within Visual Fox Pro. The code I pasted below if in a command button execute sub.

So here is what does work:

Code:
?SQLEXEC(hConn,QueryType + " " + Muffin  +  " from " + TableName + " WHERE imp_date>GETDATE()-20","localcursor")
On to the code that does not work:

Code:
	?SQLEXEC(hConn,QueryType + " " + Muffin  +  " from " + TableName + " WHERE imp_date>GETDATE()-20 " + " union " + QueryType + " " + Muffin2  +  " from " + TableName2 + " WHERE imp_date>GETDATE()-20 ","localcursor")
Any and all help is appreciated.