Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/09/2011, 09:38
Avatar de lokoman
lokoman
 
Fecha de Ingreso: septiembre-2009
Mensajes: 502
Antigüedad: 15 años, 6 meses
Puntos: 47
Respuesta: problema con consulta sql (insert)

Hola!
Creo que asi debe funcionar:

Código vb:
Ver original
  1. myconn.Execute "INSERT INTO sin_codigo(Codigo) VALUES (" & rs2!COD_TITULAR & ")"

El insert no acepta la clausula "WHERE".

Código SQL:
Ver original
  1. Syntax
  2. INSERT [ INTO]
  3.     { TABLE_NAME WITH ( < table_hint_limited > [ ...n ] )
  4.         | view_name
  5.         | rowset_function_limited
  6.     }
  7.  
  8.     {    [ ( column_list ) ]
  9.         { VALUES
  10.             ( { DEFAULT | NULL | expression } [ ,...n] )
  11.             | derived_table
  12.             | execute_statement
  13.         }
  14.     }
  15.     | DEFAULT VALUES
  16.  
  17. < table_hint_limited > ::=
  18.     { FASTFIRSTROW
  19.         | HOLDLOCK
  20.         | PAGLOCK
  21.         | READCOMMITTED
  22.         | REPEATABLEREAD
  23.         | ROWLOCK
  24.         | SERIALIZABLE
  25.         | TABLOCK
  26.         | TABLOCKX
  27.         | UPDLOCK
  28.     }

Lo que podrias hacer es un "SELECT" con el "WHERE Cedula_Titular = 1" y si se encuentra el registro, entonces haces el "INSERT"