De Oscar Romo HOLA LUIS, COMO SIEMPRE DANDOTE LATA ESPERO Y ME PUEDAS AYUDAR. GRACIAS DE ANTEMANO ESTOY MIGRANDO UNA BASE DE DATOS EN ACCESS A SQL, SOLO QUE TENGO UN PEQUEÑO PROBLEMITA PARA VACIAR UNA DE LAS TABLAS. LO INTERESANTE DEL PROYECTO ES QUE TENEMOS 9 SUCURSALES A NIVEL NACIONAL, Y AHORITA CADA QUIEN MANEJA SU BASE DE DATOS EN ACCESS DE FORMA INDEPENDIENTE. ESTAMOS MIGRANDO A SQL PARA CENTRALIZAR LA BASE DE DATOS, TODO IBA BIEN HASTA QUE AHORA TENGO QUE COPIAR LOS REGISTROS DE LAS TABLAS DE ACCESS A SQL, Y MI PROBLEMA SE PRESENTA EN LA TABLA DE SOCIOS, DEBIDO A QUE ES UN ID UNICO A NIVEL NACIONAL Y LA BASE QUE TENEMOS EN MEXICO YA TIENE LA MAYOR PARTE DE SOCIOS DE TODAS NUESTRAS SUCURSALES. AHORA BIEN TENGO QUE DISEÑAR UN PROCEDIMIENTO O UN JOB, NO SE QUE ME ACONSEJES SEA MEJOR, PARA QUE COMPARE LAS TABLAS DE SOCIOS DE AMBAS BASES DE DATOS, LA DE MEXICO Y LA DE OTRA SUCURSAL, Y QUE VALIDE SI SU NUMERO DE FICHA NO EXISTE LO AGREGUE, ESO YA LO HICE. LO QUE ME ESTA DANDO LATA ES QUE SI NO EXISTE TIENE QUE RECORRER TRES TABLAS EXTRAS LA DE PRESTAMOS, COBROS Y DOCUMENTOS DE AMBAS BASES DE DATOS ES DECIR, MEXICO Y LA DE LA OTRA SUCRUSAL, Y BUSCAR EL MOVIMIENTO DE LA FECHA MAS RECIENTE. SI LA FECHA DEL MOVIMIENTO MAS RECIENTE ES LA DE MEXICO EL REGISTRO SE QUEDA TAL CUAL SIN NINGUN MOVIMIENTO, POR OTRO LADO SI SU FECHA DE MOVIMIENTO MAS RECIENTE ES EL DE LA SUCURSAL SUSTITUIR EN LA TABLA DE SOCIOS DE LA BASE DE MEXICO AL SOCIO. OJALA ME PUEDAS AYUDAR A DESCIFRAR ESTE ENIGMA YA QUE NO ENCUENTRA LA FORMA DE HACER HE TRATADO DE HACERLO MEDIANTE SELECTS Y ALGO DE PROGRAMACION PERO NO ENCUENTRO LA FORMA. Te comento un poco de la estructura de nuestras tablas involucradas Este es nuestra tabla SOCIOS y sus campos son: Numero_Socio, Numero_Registro, Tipo_Socio, Categoria_Socio, Cve_Nomina, Fecha_Ingreso, Cve_Profesion, Cve_Localidad, Paterno, Materno, Nombre, Edo_Civil, RFC, Domicilio, Colonia, Cod_Postal, Cve_Delegacion, Cve_Empresa, Cve_Centro, Cve_Depto, Cve_Nivel, Fec_Alta_Cons, Fec_Alta_Asam, Fec_Prot_Fam, Telefono_Part, Telefono_dir, Telefono_Conm, Extension, Celular, Fax, E_Mail, Tel_Localiza, Cve_Localiza, Banco, Cuenta, Plaza, Sucursal, Tipo_Cuenta, Mot_Baja, Fec_Baja_Cons, Fec_Baja_Sistem, Fec_Alta_Sistem, UsuModi, FecModi, HorModi, Sexo, ActualizarDomicilio, CURP, MaquinaModify,Clabe, ClabeBan, ActualizaDatos, Reingreso, Foto, Firma, Sucursal las tablas de socios en las sucursales del interior tienen la misma estructura y la tabla de socios prinicpal, México, ya tiene algunos registros de las tablas de socios de las demas sucursales. esta es nuestra tabla de COBROS: Numero_Socio, Num_doc_Gral, Num_Pago, Fecha_Movi, Monto_Catorcenal, Monto_Cobrado, Periodo_Cobro, Edo_Cobro, Procedencia, Num_Recibo, Cve_Nomina, Desc_Concepto, Saldo_Acreedor,Ajuste, UsuModi, FecModi, HorModi, RegMod, CargoNo, Vacio, Comentario, Sucursal esta es nuestra tabla de DOCUMENTOS Num_doc_Gral, Cve_concepto, Numero_Socio, NumDocto, EdoDocto, Monto, Fec_Doc, Num_Pagos, descuento_Catorcenal, num_pagos, usuario, proveedor, sucursal estas tablas se manejan por separado, es decir, cada sucursal genera sus cobros y documentos y tengo también la de prestamos y cuotas también con una estructura muy similar a la de cobros. Como comentaba en mi primera pregunta, tengo que recorrer todas estas tablas tanto en México como en la delegación a copiar para revisar cual tiene el pago o el movimiento más reciente y tomarlo como base para sustituirlo o no en la tabla de socios principal, es decir México. GRACIAS DE ANTEMANO Y SALUDOS Luis Martin Moderator SQL-Server-Performance.com One of the symptoms of an approaching nervous breakdown is the belief that one's work is terribly important Bertrand Russell All postings are provided “AS IS†with no warranties for accuracy.
No me queda claro el tipo de ayuda que te podemos dar. Supongo que ya habrás puesto todas las tablas en SQL Server. 1) Yo pondrÃa en una nueva tabla todo lo que no pudiste asociar. 2) Le crearÃa a la tabla un identity y la recorrerÃa registro 3) Para cada registro, realizarÃa la busqueda en las otras sucursales 4) Segun la respuesta actualizacia en la tabla centralizadora 5) Paso al nuevo registro. Ej: CREATE TABLE NoAsociados ( nRow int identity(1,1), Campo1 ,..etc..etc.. ) Declare @nRow int,@nRowMax int Select @nRow = min(nRow), @nRowMax = max(nRow) From NoAsociados While @nRow <= @nRowMax Begin --- Leo en variables el primer registro Select @Campo1 = Campo1, ..... From NoAsociados Where nRow = @nRow --- Realizo las busquedas --- Decido --- Actualizo --- Paso al próximo Set @nRow = @nRow + 1 End PodrÃa utilizarse un cursor. Saludos
Not that I understand the text, but I see looping with a cursor. If someone can describre what's requested maybe we find a workaround without a cursor. -- Frank Kalis Microsoft SQL Server MVP http://www.insidesql.de Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)
Thank Frank, but: 1) Original post came to me via e-mail, so I don´t think he will read this one. 2) As C_Maldon said is hard to translate because is no clair what the guy need. Luis Martin Moderator SQL-Server-Performance.com One of the symptoms of an approaching nervous breakdown is the belief that one's work is terribly important Bertrand Russell All postings are provided “AS IS†with no warranties for accuracy.
...well then ... [<img src='/community/emoticons/emotion-4.gif' alt='' />]<br /><br />--<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Ich unterstütze PASS Deutschland e.V. <a target="_blank" href=http://www.sqlpass.de>http://www.sqlpass.de</a>) <br />
No te preocupes, Frank que es experto en desarrollo, miró tu código y le parece que se puede mejorar sin el uso de cursores, pero querÃa conocer un poco más del problema original. Yo le respondà que el post original lo recibà por mail y que no creÃa que el autor lo vaya a leer. No obstante si vos querés, puedo traducir todo para él y, quizás, vos saques provecho. Saludos, Luis Martin Moderator SQL-Server-Performance.com One of the symptoms of an approaching nervous breakdown is the belief that one's work is terribly important Bertrand Russell All postings are provided “AS IS†with no warranties for accuracy.
Claro que no Luis Martin, sigo aquà al pendiente de lo que me puedan recomendar. Ya logre hacer una parte con el uso de cursores para recorre una tabla nueva que genero, en eso estoy y estoy al pendiente porque lo escrito aquà me ha ayudado mucho Gracias
Mil disculpas Oscar, al no tener respuestas a las sugerencias evidentemente equivoqué la interpretación. Luis Martin Moderator SQL-Server-Performance.com One of the symptoms of an approaching nervous breakdown is the belief that one's work is terribly important Bertrand Russell All postings are provided “AS IS†with no warranties for accuracy.