Greetings! I am very new to SQL. I need to be able to query a read only SQL database on Server A and store the results on Server B where I do have permissions to right tables.

I tried this, but I am missing something? Any ideas?

Sub MakeServerTblUsingODBC()
Dim strSql As String

strSql = "SELECT * INTO
[ODBC;DSN=BSSF;DATABASE=D_STM_BSSF;Trusted_Connecti on=Yes;].tbl_NJ_UW_PART_A

FROM (((((D_STMEDB.dbo.T_LN INNER JOIN D_STMEDB.dbo.T_UW ON D_STMEDB.dbo.T_LN.LN_ID = D_STMEDB.dbo.T_UW.LN_ID) INNER JOIN D_STMEDB.dbo.T_PRPTY ON D_STMEDB.dbo.T_LN.LN_ID = D_STMEDB.dbo.T_PRPTY.LN_ID) INNER JOIN D_STMEDB.dbo.T_CTR ON D_STMEDB.dbo.T_LN.PROD_CTR_CD = D_STMEDB.dbo.T_CTR.CTR_CD) INNER JOIN D_STMEDB.dbo.T_HMDA_LN ON D_STMEDB.dbo.T_LN.LN_ID = D_STMEDB.dbo.T_HMDA_LN.LN_ID) INNER JOIN D_STMEDB.dbo.V_PIVOT_LN_STAT ON D_STMEDB.dbo.T_LN.LN_ID = D_STMEDB.dbo.V_PIVOT_LN_STAT.ln_id) INNER JOIN D_STMEDB.dbo.T_GHR_MLCS_INTRFC ON D_STMEDB.dbo.T_LN.LN_ID = D_STMEDB.dbo.T_GHR_MLCS_INTRFC.LN_ID

WHERE (((D_STMEDB.dbo.T_PRPTY.SUBJ_PRPTY_ST_CD)='nj') AND ((D_STMEDB.dbo.T_UW.CRED_PKG_RECV_DT)>='9/17/2009') AND ((D_STMEDB.dbo.T_CTR.ORIG_CHNL)='b')) OR (((D_STMEDB.dbo.T_PRPTY.SUBJ_PRPTY_ST_CD)='nj') AND ((D_STMEDB.dbo.T_CTR.ORIG_CHNL)='b') AND ((D_STMEDB.dbo.V_PIVOT_LN_STAT.APP_AGG_ENT_DT)>=ge tdate()-7)) OR (((D_STMEDB.dbo.T_PRPTY.SUBJ_PRPTY_ST_CD)='nj') AND ((D_STMEDB.dbo.T_CTR.ORIG_CHNL)='r') AND ((D_STMEDB.dbo.V_PIVOT_LN_STAT.APP_AGG_ENT_DT)>=ge tdate()-7)) OR (((D_STMEDB.dbo.T_PRPTY.SUBJ_PRPTY_ST_CD)='nj') AND ((D_STMEDB.dbo.T_CTR.ORIG_CHNL)='r') AND ((D_STMEDB.dbo.T_HMDA_LN.INIT_DISCLS_TRIG_DT) Is Not Null) AND ((D_STMEDB.dbo.T_GHR_MLCS_INTRFC.GHR_SUBM_DT_XMIT_ RECV_DT)>='9/17/2009')) OR (((D_STMEDB.dbo.T_PRPTY.SUBJ_PRPTY_ST_CD)='nj') AND ((D_STMEDB.dbo.T_CTR.ORIG_CHNL)='r') AND ((D_STMEDB.dbo.T_HMDA_LN.INIT_DISCLS_TRIG_DT)>='9/17/2009'));"

DoCmd****nSql strSql

End Sub


I get the following error:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ')'.
Server: Msg 103, Level 15, State 1, Line 4
The identifier that starts with 'SELECT * INTO
[ODBC;DSN=BSSF;DATABASE=D_STM_BSSF;Trusted_Connecti on=Yes;].tbl_NJ_UW_PART_A

FROM (((((D_STMEDB.dbo.T_LN INNER' is too long. Maximum length is 128.