Insert & Union All Select

JonyBravo

Registered User.
Local time
Tomorrow, 01:44
Joined
Jan 17, 2006
Messages
89
Hi

I've written the following SQL code that is not working:
SQL = "INSERT INTO tbltest5 ( TLI, [Switch Name], NNI, [BT CB], [Time Period], Calls )"
SQL = SQL & "SELECT tbltest2.TLI, tbltest2.[Switch Name], tbltest2.NNI, tbltest2.[BT CB], tbltest2.[Time Period], tbltest2.Calls"
SQL = SQL & " FROM tbltest2 WHERE (((tbltest2.TLI) Like [txt1]));"
SQL = SQL & " UNION ALL SELECT tbltest.TLI, tbltest.[Switch Name], tbltest.NNI, tbltest.[BT CB], tbltest.[Time Period], tbltest.Calls"
SQL = SQL & " FROM tbltest"
SQL = SQL & " WHERE (((tbltest.TLI) Like [txt1]));"
SQL = SQL & " UNION ALL SELECT tbltest3.TLI, tbltest3.[Switch Name], tbltest3.NNI, tbltest3.[BT CB], tbltest3.[Time Period], tbltest3.Calls"
SQL = SQL & " FROM tbltest3"
SQL = SQL & " WHERE (((tbltest3.TLI) Like [txt1]));"

Is this possible to work?
 
why not simply construct the union query as a standalone query and then an append query whose source is the Union query

Fire the Append query and Union query will automatically be run

Much easier to understand and debug

Len
 

Users who are viewing this thread

Back
Top Bottom