Private Sub obtener_definicion_tabla(tabid As Long, tabname As String) Dim sql As String Dim primera_columna As Boolean Dim rs As ADODB.Recordset primera_columna = True With txtCreates .Text = .Text & " CREATE TABLE " & tabname & " (" & vbCrLf txtUnloads.Text = txtUnloads.Text & " UNLOAD TO 'd:\ " & tabname & ".unl' " txtUnloads.Text = txtUnloads.Text & " SELECT " sql = "select colno, colname, coltype, collength " _ & " from syscolumns" _ & " where tabid = " & tabid _ & " and not (colname like 'hash%' or colname like 't_refcnt%') " _ & " order by colno " Set rs = conn.Execute(sql) While Not rs.EOF .Text = .Text & IIf((primera_columna), "", ", " & vbCrLf) & rs!colname & vbTab Select Case (rs!coltype - 256) Case 0: .Text = .Text & "CHAR(" & rs!collength & ") " Case 1: .Text = .Text & "SMALLINT " Case 2: .Text = .Text & "INTEGER " Case 3: .Text = .Text & "FLOAT " Case 4: .Text = .Text & "FLOAT " Case 7: .Text = .Text & "DATE " Case Else .Text = .Text & " UNKNOWN_TYPE (" & rs!coltype - 256 & ") " End Select txtUnloads.Text = txtUnloads.Text & IIf((primera_columna), "", ", ") & rs!colname primera_columna = False rs.MoveNext Wend .Text = .Text & ", vacio integer ); " & vbCrLf & vbCrLf txtUnloads.Text = txtUnloads.Text & " FROM " & tabname & "; " & vbCrLf & vbCrLf txtLoads.Text = txtLoads.Text & "load from '" & tabname & ".unl' insert into " _ & tabname & ";" & vbCrLf & vbCrLf End With ' Call conn.Execute(txtUnloads.Text) rs.Close End Sub