I have the following code to run sql commands as pass-throughs...
It generally runs without a hitch. I passed through an SQL statement to create a table (something new I'm trying). I can pass a command successfully to DROP a table. But CREATE TABLE does nothing. However, when I directly copy the sql statement and paste it into SSMS, and run it, it works fine.
Any suggestions? Thanks!
Code:
Sub subRunSQL(pSQL As String, Optional pPrint As Boolean)
On Error Resume Next
Dim qdf As DAO.QueryDef
Set qdf = CurrentDb.CreateQueryDef("")
qdf.Connect = gsConnection
qdf.sql = pSQL
qdf.ReturnsRecords = False
If pPrint = True Then Debug.Print pSQL
qdf.Execute
qdf.Close
Set qdf = Nothing
End Sub
It generally runs without a hitch. I passed through an SQL statement to create a table (something new I'm trying). I can pass a command successfully to DROP a table. But CREATE TABLE does nothing. However, when I directly copy the sql statement and paste it into SSMS, and run it, it works fine.
Any suggestions? Thanks!