Insertar cursor en tabla temporal sql
Publicado por Gastón (80 intervenciones) el 06/05/2010 14:48:24
Hola amigos, por favor necesito que me den una mano con un problema que tengo.
Tengo un cursor con tres campos (Documento, Unidades, Coste) y necesito insertar ese cursor en una tabla temporal en el SQL, mi codigo es este y no me ha funcionado.
**CREO LA TABLA
myconexion = SQLCONNECT("Almacen")
consulta = "create table #gaston (temp_doc int, temp_unidades int, temp_coste dec)"
SQLEXEC(myconexion,consulta)
**COMPRUEBO QUE LA TABLA EXISTE Y GENERO UN CURSOR
query = "Select* from #gaston"
SQLEXEC(myconexion,query,"Cur_Gaston") *******Hasta aquí funciona
**INSERTO LOS DATOS DEL CURSOR (cur_tlescostes) EN LA TABLA TEMPORAL #gaston
consultasql = "insert into tempdb..#gaston select* from cur_tlescostes"
SQLEXEC(myconexion,consultasql)
temporal = "select * from tempdb..#gaston"
SQLEXEC(myconexion,temporal,"cur_gaston")
Gracias y espero que me puedan ayudar.
Un saludo.
Tengo un cursor con tres campos (Documento, Unidades, Coste) y necesito insertar ese cursor en una tabla temporal en el SQL, mi codigo es este y no me ha funcionado.
**CREO LA TABLA
myconexion = SQLCONNECT("Almacen")
consulta = "create table #gaston (temp_doc int, temp_unidades int, temp_coste dec)"
SQLEXEC(myconexion,consulta)
**COMPRUEBO QUE LA TABLA EXISTE Y GENERO UN CURSOR
query = "Select* from #gaston"
SQLEXEC(myconexion,query,"Cur_Gaston") *******Hasta aquí funciona
**INSERTO LOS DATOS DEL CURSOR (cur_tlescostes) EN LA TABLA TEMPORAL #gaston
consultasql = "insert into tempdb..#gaston select* from cur_tlescostes"
SQLEXEC(myconexion,consultasql)
temporal = "select * from tempdb..#gaston"
SQLEXEC(myconexion,temporal,"cur_gaston")
Gracias y espero que me puedan ayudar.
Un saludo.
Valora esta pregunta


0