Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL copy table values to new table
    primarykey
    data
    text
    <p>Hello I am trying to copy the values which is in excel sheet to new table in same database using <code>Select * INTO query</code>. </p> <p>The data which is extracted to excel is from other table and after editing some columns in excel, I need the excel sheet to be sent back to SQL database with new table creation. </p> <p>I got problem with my code which says error :</p> <pre><code>Run- time error '-2147217900 ' Automation Error </code></pre> <p>I am using <em>VBA Macros</em> to import and export the table values to <em>SQL from Excel</em>.</p> <p>Here is my Code </p> <pre><code>Dim adoCN As ADODB.Connection Dim sConnString As String Dim sSQL As String Dim lRow As Long, lCol As Long sConnString = "Provider=sqloledb;Server=;Database=mycon;User Id=;Password=" Set adoCN = CreateObject("ADODB.Connection") adoCN.Open sConnString 'Assumes that you have Field1, Field2 and Field3 in columns A, B and C 'For this example we can assume that the data exists on Sheet1, with a header on row '1 and data in rows 2-11 'Also assume that the fields are defined as character (e.g. varchar or char) 'Text values must be enclosed in apostrophes whereas numeric values should not. 'adoCN.Open For lRow = 1 To ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row sSQL = "SELECT * INTO TestTable FROM Sheets(1)$" ***adoCN.Execute sSQL*** Next lRow adoCN.Close Set adoCN = Nothing 'On Error GoTo 0 </code></pre> <p>Error at Line : <strong><em>adoCN.Execute sSQL</em></strong></p> <p>Please help me out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload