m.lhSQL = SQLSTRINGCONNECT(".....") && Connection string to SQL Server IF m.lhSQL < 0 AERROR(laError) MessageBox("Can not connect to SQL Server. Reason: "+laError[1,2]) RETURN ENDIF TEXT TO m.lcSQLStatement NOSHOW *** Here paste the copied query from Query analyzer ENDTEXT IF SQLEXEC(m.lhSQL, m.lcSQLStatement) < 0 AERROR(laError) MessageBox("Can not execute SQL Statement. Reason: "+laError[1,2]) ENDIF SQLDISCONNECT(m.lhSQL)