Últimos mensajes - Powered by IBM
- Normalización
- Normalización
- Error -2147221503 [ODBC SQL Server ...
- Sql Server Backups
- sql server
- informe de consumo mensual
- rangos de fecha
- error con instancia en sql server 2005 express ...
- Conexion via Programacion a SQL SERVER 2008 R2
- Exportar datos desde un archivo de Texto a SQL ...
Palabras claves
Cordial saludo, tenemos un sp que realiza
insert into.. selects y updates a una tabla en forma masiva.
pero el problema radica es que haciendo esto bloquea la tabla
syscolumns y se come el procesador por tanto todos los procesos quedan
casi inoperantes,cuando esta realizando el insert o los updates ,el sp
produce el bloqueo contra un proceso del servidor (spid) que es uno
de los procesos default( o llamemoslo del sistema )del sql server,este
es el sp, gracias por su ayuda...
Jose Nadim Mendez
CREATE procedure TEM00
as
truncate table TemTe4
truncate table Tem003
Insert into Tem003 ( T03TdiCab, T03IdeCab, T03AfiTdiC, T03AfiIde,
T03ApePri, T03ApeSeg, T03NomPri, T03NomSeg,
T03FecNac, T03Sex, T03AfiTip, T03ParCod, T03CAfCod, T03FecStm,
T03FecAfi,
T03FecGra, T03FecIPos, T03FecFSer, T03SemCer, T03SemCSis, T03SemCApb,
T03FecRet, T03MunCAte, T03RanSal, T03TfuCod, T03FuiNum, T03ApbCAnt,
T03AseCod,
T03FecUAfi,T03FecAct, T03TipDis, T03Zon, T03TdiCon, T03IdeCon,
T03TnaCod,
T03CreCod, T03IndEsp, T03UsuCod, T03AfiEst, T03AfiFecR, T03AfiFecA,
T03AfiFecU, T03MunNAte)
SELECT rtrim(A.AfiTdiCab), rtrim(A.AfiIdeCab),
rtrim(A.AfiTdiCod), rtrim(A.AfiIde),
rtrim(A.AfiApePri), rtrim(A.AfiApeSeg),
rtrim(A.AfiNomPri), rtrim(A.AfiNomSeg),
CONVERT(CHAR(10),A.AfiFecNac,111), A.AfiSex,
rtrim(A.AfiTip), rtrim(A.AfiParCod),
rtrim(A.AfiCafCod),CONVERT(CHAR(10),A.AfiFecStm,111),
CONVERT(CHAR(10),A.AfiFecAfi,111),
CONVERT(CHAR(10),A.AfiFecGra,111),
CONVERT(CHAR(10),A.AfiFecIPos,111),
CONVERT(CHAR(10),A.AfiFecFSer,111),
A.AfiSemCer, A.AfiSemCSis, A.AfiSemCApb,
CONVERT(CHAR(10),A.AfiFecRet,111),
rtrim(A.AfiMunCAtE),
rtrim(A.AfiRanSal), rtrim(A.AfiTfuCod),
rtrim(A.AfiFuiNum), rtrim(A.AfiApbCAnt),
rtrim(A.AfiAseCod), CONVERT(CHAR(10),A.AfiFecUAfi,111),
CONVERT(CHAR(10),A.AfiFecAct,111), rtrim(A.AfiTipDis),
rtrim(A.AfiZon), rtrim(A.AfiTdiCon),
rtrim(A.AfiIdeCon), rtrim(A.AfiTnaCod),
rtrim(A.AfiCreCod), rtrim(A.AfiIndEsp),
rtrim(A.AfiUsuCod), rtrim(A.AfiEst),
AfiFecRet, AfiFecAfi, AfiFecUAfi, M.MunNom
From MUNICIPI M RIGHT OUTER JOIN AFILIADO A ON M.MunCod A.AfiMunCAte
WHERE A.AFIPLACOD = 'CON' AND A.AFIEST < '7'
Update T
Set T.T03EmpTdi = E.EmpTdiCod, T.T03EmpIde = E.EmpIde,
T.T03ESucCod = E.ESucCod, T.T03TviCod = E.EmCoTviCod,
T.T03SalBas = E.EmCoSalBas
from EMPCOT E RIGHT OUTER JOIN TEM003 T ON E.CotTdiCod T.T03AfiTdiC AND
E.CotIde T.T03AfiIde
WHERE E.EMCOEST = '1' and E.Emcofecret = '01/01/1753' AND
T.T03AfiEst < '5' and
E.EMCOFECING =(Select Min(B.EMCOFECING) FROM EMPCOT b
where b.EMCOEST = '1' and B.Emcofecret '01/01/1753' and
E.COTtdicod=B.COTtdicod and
E.COTIDE=B.COTIDE )
Update T
Set T.T03EmpTdi = E.EmpTdiCod, T.T03EmpIde = E.EmpIde,
T.T03ESucCod = E.ESucCod, T.T03TviCod = E.EmCoTviCod,
T.T03SalBas = E.EmCoSalBas
from EMPCOT E RIGHT OUTER JOIN TEM003 T ON E.CotTdiCod T.T03AfiTdiC AND
E.CotIde T.T03AfiIde
WHERE E.EMCOEST = '1' and E.Emcofecret <> '01/01/1753' AND
T.T03AfiEst = '5' and
E.EMCOFECING =(Select Min(B.EMCOFECING) FROM EMPCOT b
where b.EMCOEST = '1' and B.Emcofecret <>
'01/01/1753' and
E.COTtdicod=B.COTtdicod and
E.COTIDE=B.COTIDE )
Update T
Set T.T03IpsCod = i.iafipscod,
T.T03SipCod = i.iafsipcod,
T.T03SipNom = s.sipnom
From SECIPS S RIGHT OUTER JOIN IPSAFI I ON S.IpsCod = I.IafIpsCod AND
S.SipCod = I.IafSipCod
RIGHT OUTER JOIN TEM003 T ON I.IafAfiTdiC = T.T03AfiTdiC
AND
I.IafAfiIde = T.T03AfiIde
WHERE I.IafEst = '1' and I.IafIpsBas = 'B'
Update T
Set T.T03CotTip = C.CotTip,
T.T03DirRes = A.AfiDirRes,
T.T03TelRes = A.AfiTelRes,
T.T03MunCRes = A.AfiMunCRes
from COTIZANT C JOIN TEM003 T ON C.CotTdiCod = T.T03AfiTdiC AND
C.CotIde = T.T03AfiIde
JOIN AFILIADO A ON A.AfiTdiCod = T.T03AfiTdiC AND
A.AfiIde = T.T03AfiIde
Update T
Set T.T03ESucNom = E.ESucNom,
T.T03ESucDir = E.ESucDir,
T.T03ESucFax = E.ESucFax,
T.T03ESucTel = E.ESucTel,
T.T03ESucMun = E.ESucMunCod
from Emplead1 E JOIN TEM003 T ON E.EmpTdiCod = T.T03EmpTdi AND
E.EmpIde = T.T03EmpIde AND
E.ESucCod = T.T03ESucCod
Update T
Set T.T03CotTip = T1.T03CotTip,
T.T03DirRes = T1.T03DirRes,
T.T03TelRes = T1.T03TelRes,
T.T03MunCRes = T1.T03MunCRes,
T.T03EmpTdi = T1.T03EmpTdi,
T.T03EmpIde = T1.T03EmpIde,
T.T03ESucCod = T1.T03ESucCod,
T.T03ESucNom = T1.T03ESucNom,
T.T03ESucDir = T1.T03ESucDir,
T.T03ESucFax = T1.T03ESucFax,
T.T03ESucTel = T1.T03ESucTel,
T.T03ESucMun = T1.T03ESucMun,
T.T03TviCod = T1.T03TviCod,
T.T03SalBas = T1.T03SalBas
FROM TEM003 T INNER JOIN
TEM003 T1 ON
T.T03TdiCab = T1.T03AfiTdiC AND
T.T03IdeCab = T1.T03AfiIde
Update TEM003
Set T03VSEMCER=(CASE WHEN T03SEMCER >0 THEN T03SEMCER ELSE T03SEMCSIS
END),
T03VSEMCAP(CASE WHEN T03AFIFECU >getdate() THEN 0
ELSE
(CASE WHEN T03SEMCAPB >0 THEN T03SEMCAPB
ELSE(CASE WHEN T03AFIEST<5 THEN
((datediff(DAY,T03Afifeca,getdate()))/7)
ELSE ((DATEDIFF(DAY,T03afifeca,T03afifecr))/7)
END)
END)
END),
T03VSEMTOT(CASE WHEN T03SEMCER >0 THEN T03SEMCER ELSE T03SEMCSIS END)+
(CASE WHEN T03AFIFECU >getdate() THEN 0
ELSE
(CASE WHEN T03SEMCAPB >0 THEN T03SEMCAPB
ELSE(CASE WHEN T03AFIEST<5 THEN
((datediff(DAY,T03afifeca,getdate()))/7)
ELSE ((DATEDIFF(DAY,T03afifeca,T03afifecr))/7)
END)
END)
END)
from TEM003 (nolock fastfirstrow)
suspensión
UPDATE dbo.TEM003
SET T03TnaCod = 'NA', T03CreCod = 'NA'
WHERE (T03AfiEst <> '3')
UPDATE dbo.TEM003
SET T03COTTIP = '9', T03DIRRES = 'NA', T03TELRES = 'NA', T03MUNCRES 'NA'
FROM dbo.TEM003
WHERE T03DIRRES IS NULL
UPDATE dbo.TEM003
SET T03EMPTDI = 'NA', T03EMPIDE = 'NA', T03ESUCCOD = 'NA', T03ESUCNOM
= 'NA',
T03ESUCDIR = 'NA', T03ESUCFAX = 'NA', T03ESUCTEL = 'NA',
T03ESUCMUN = 'NA',
T03TVICOD = 'NA', T03SALBAS = 0
FROM dbo.TEM003
WHERE T03EMPIDE IS NULL
UPDATE dbo.TEM003
SET T03IPSCOD = 'NA', T03SIPCOD = 'NA', T03SIPNOM = 'NA'
FROM dbo.TEM003
WHERE T03IPSCOD IS NULL
Insert Into TemTe4(Te4Cod, Te4Reg)
SELECT Cast(T03Secuenc as Char(8)), rtrim(T03FecStm) +
';' + rtrim(T03FecAfi) + ';' +
rtrim(T03ApePri) + ';' + rtrim(T03ApeSeg) +
';' +
rtrim(T03NomPri) + ' ' + rtrim(T03NomSeg) +
';' +
rtrim(T03AfiIde) + ';' + rtrim(T03AfiTdiC) +
';' +
rtrim(T03FecNac) + ';' + (CASE T03AfiTip
WHEN '1' THEN 'Cot'
WHEN '2' THEN 'Ben'
WHEN '3' THEN 'B/C'
WHEN '4' THEN 'Adi'
WHEN '5' THEN 'Cab'
WHEN '6' THEN 'Sus'
WHEN '7' THEN 'Tut'
ELSE 'NDE'
END)+ ';' +
rtrim(T03Sex) + ';' + rtrim(T03ParCod) +
';' +
rtrim(T03DirRes) + ';' + rtrim(T03TelRes) +
';' +
rtrim(T03MunCRes) + ';' + rtrim(T03MunCAtE) +
';' +
rtrim(T03MunNAte) + ';' + rtrim(T03EmpTdi) +
';' +
rtrim(T03EmpIde) + ';' + rtrim(T03ESucCod) +
';' +
rtrim(T03ESucNom) + ';' + (CASE T03AfiEst
WHEN '1' THEN 'Act'
WHEN '3' THEN 'Sus'
WHEN '5' THEN 'Pro'
WHEN '7' THEN 'Ret'
WHEN '8' THEN 'Por'
WHEN '9' THEN 'Ina'
ELSE 'NA '
END)+ ';' +
rtrim(T03RANSAL) + ';' +
rtrim(T03TfuCod) + ';' +
RTRIM(CONVERT(CHAR(10),T03FuiNum))+ ';'+
rtrim(T03IpsCod) + ';' + rtrim(T03SipCod)
+ ';'+
rtrim(T03SipNom) + ';' + rtrim(T03FecGra)
+ ';'+
(CASE T03CafCod
WHEN '01' THEN 'OA'
WHEN '02' THEN 'NU'
WHEN '03' THEN 'CR'
WHEN '04' THEN 'NA'
WHEN 'CO' THEN 'CO'
ELSE 'ND'
END)+ ';' +
rtrim(T03ApbCAnt) + ';' +
rtrim(T03TdiCab) + ';' + rtrim(T03IdeCab) + ';'+
rtrim(CONVERT(CHAR(20),T03VSEMTOT))+';' +
rtrim(CONVERT(CHAR(20),T03SalBas))+ ';' +
rtrim(T03AseCod) + ';' + rtrim(T03FecIPos) + ';'+
rtrim(T03FecFSer) + ';' + rtrim(T03ESucDir)
+ ';'+
rtrim(T03ESucFax) + ';' + rtrim(T03ESucTel)
+ ';'+
rtrim(T03ESucMun) + ';' + rtrim(T03CotTip)
+ ';'+
rtrim(T03TviCod) + ';' + rtrim(T03FecUAfi)
+ ';'+
rtrim(T03FecAct) + ';' + rtrim(T03TipDis)
+ ';'+
rtrim(T03Zon) + ';' + rtrim(T03TdiCon)
+ ';'+
rtrim(T03IdeCon) + ';' + rtrim(T03TnaCod)
+ ';'+
rtrim(T03CreCod) + ';' + rtrim(T03IndEsp)
+ ';'+
rtrim(T03UsuCod)
From TEM003
insert into.. selects y updates a una tabla en forma masiva.
pero el problema radica es que haciendo esto bloquea la tabla
syscolumns y se come el procesador por tanto todos los procesos quedan
casi inoperantes,cuando esta realizando el insert o los updates ,el sp
produce el bloqueo contra un proceso del servidor (spid) que es uno
de los procesos default( o llamemoslo del sistema )del sql server,este
es el sp, gracias por su ayuda...
Jose Nadim Mendez
CREATE procedure TEM00
as
truncate table TemTe4
truncate table Tem003
Insert into Tem003 ( T03TdiCab, T03IdeCab, T03AfiTdiC, T03AfiIde,
T03ApePri, T03ApeSeg, T03NomPri, T03NomSeg,
T03FecNac, T03Sex, T03AfiTip, T03ParCod, T03CAfCod, T03FecStm,
T03FecAfi,
T03FecGra, T03FecIPos, T03FecFSer, T03SemCer, T03SemCSis, T03SemCApb,
T03FecRet, T03MunCAte, T03RanSal, T03TfuCod, T03FuiNum, T03ApbCAnt,
T03AseCod,
T03FecUAfi,T03FecAct, T03TipDis, T03Zon, T03TdiCon, T03IdeCon,
T03TnaCod,
T03CreCod, T03IndEsp, T03UsuCod, T03AfiEst, T03AfiFecR, T03AfiFecA,
T03AfiFecU, T03MunNAte)
SELECT rtrim(A.AfiTdiCab), rtrim(A.AfiIdeCab),
rtrim(A.AfiTdiCod), rtrim(A.AfiIde),
rtrim(A.AfiApePri), rtrim(A.AfiApeSeg),
rtrim(A.AfiNomPri), rtrim(A.AfiNomSeg),
CONVERT(CHAR(10),A.AfiFecNac,111), A.AfiSex,
rtrim(A.AfiTip), rtrim(A.AfiParCod),
rtrim(A.AfiCafCod),CONVERT(CHAR(10),A.AfiFecStm,111),
CONVERT(CHAR(10),A.AfiFecAfi,111),
CONVERT(CHAR(10),A.AfiFecGra,111),
CONVERT(CHAR(10),A.AfiFecIPos,111),
CONVERT(CHAR(10),A.AfiFecFSer,111),
A.AfiSemCer, A.AfiSemCSis, A.AfiSemCApb,
CONVERT(CHAR(10),A.AfiFecRet,111),
rtrim(A.AfiMunCAtE),
rtrim(A.AfiRanSal), rtrim(A.AfiTfuCod),
rtrim(A.AfiFuiNum), rtrim(A.AfiApbCAnt),
rtrim(A.AfiAseCod), CONVERT(CHAR(10),A.AfiFecUAfi,111),
CONVERT(CHAR(10),A.AfiFecAct,111), rtrim(A.AfiTipDis),
rtrim(A.AfiZon), rtrim(A.AfiTdiCon),
rtrim(A.AfiIdeCon), rtrim(A.AfiTnaCod),
rtrim(A.AfiCreCod), rtrim(A.AfiIndEsp),
rtrim(A.AfiUsuCod), rtrim(A.AfiEst),
AfiFecRet, AfiFecAfi, AfiFecUAfi, M.MunNom
From MUNICIPI M RIGHT OUTER JOIN AFILIADO A ON M.MunCod A.AfiMunCAte
WHERE A.AFIPLACOD = 'CON' AND A.AFIEST < '7'
Update T
Set T.T03EmpTdi = E.EmpTdiCod, T.T03EmpIde = E.EmpIde,
T.T03ESucCod = E.ESucCod, T.T03TviCod = E.EmCoTviCod,
T.T03SalBas = E.EmCoSalBas
from EMPCOT E RIGHT OUTER JOIN TEM003 T ON E.CotTdiCod T.T03AfiTdiC AND
E.CotIde T.T03AfiIde
WHERE E.EMCOEST = '1' and E.Emcofecret = '01/01/1753' AND
T.T03AfiEst < '5' and
E.EMCOFECING =(Select Min(B.EMCOFECING) FROM EMPCOT b
where b.EMCOEST = '1' and B.Emcofecret '01/01/1753' and
E.COTtdicod=B.COTtdicod and
E.COTIDE=B.COTIDE )
Update T
Set T.T03EmpTdi = E.EmpTdiCod, T.T03EmpIde = E.EmpIde,
T.T03ESucCod = E.ESucCod, T.T03TviCod = E.EmCoTviCod,
T.T03SalBas = E.EmCoSalBas
from EMPCOT E RIGHT OUTER JOIN TEM003 T ON E.CotTdiCod T.T03AfiTdiC AND
E.CotIde T.T03AfiIde
WHERE E.EMCOEST = '1' and E.Emcofecret <> '01/01/1753' AND
T.T03AfiEst = '5' and
E.EMCOFECING =(Select Min(B.EMCOFECING) FROM EMPCOT b
where b.EMCOEST = '1' and B.Emcofecret <>
'01/01/1753' and
E.COTtdicod=B.COTtdicod and
E.COTIDE=B.COTIDE )
Update T
Set T.T03IpsCod = i.iafipscod,
T.T03SipCod = i.iafsipcod,
T.T03SipNom = s.sipnom
From SECIPS S RIGHT OUTER JOIN IPSAFI I ON S.IpsCod = I.IafIpsCod AND
S.SipCod = I.IafSipCod
RIGHT OUTER JOIN TEM003 T ON I.IafAfiTdiC = T.T03AfiTdiC
AND
I.IafAfiIde = T.T03AfiIde
WHERE I.IafEst = '1' and I.IafIpsBas = 'B'
Update T
Set T.T03CotTip = C.CotTip,
T.T03DirRes = A.AfiDirRes,
T.T03TelRes = A.AfiTelRes,
T.T03MunCRes = A.AfiMunCRes
from COTIZANT C JOIN TEM003 T ON C.CotTdiCod = T.T03AfiTdiC AND
C.CotIde = T.T03AfiIde
JOIN AFILIADO A ON A.AfiTdiCod = T.T03AfiTdiC AND
A.AfiIde = T.T03AfiIde
Update T
Set T.T03ESucNom = E.ESucNom,
T.T03ESucDir = E.ESucDir,
T.T03ESucFax = E.ESucFax,
T.T03ESucTel = E.ESucTel,
T.T03ESucMun = E.ESucMunCod
from Emplead1 E JOIN TEM003 T ON E.EmpTdiCod = T.T03EmpTdi AND
E.EmpIde = T.T03EmpIde AND
E.ESucCod = T.T03ESucCod
Update T
Set T.T03CotTip = T1.T03CotTip,
T.T03DirRes = T1.T03DirRes,
T.T03TelRes = T1.T03TelRes,
T.T03MunCRes = T1.T03MunCRes,
T.T03EmpTdi = T1.T03EmpTdi,
T.T03EmpIde = T1.T03EmpIde,
T.T03ESucCod = T1.T03ESucCod,
T.T03ESucNom = T1.T03ESucNom,
T.T03ESucDir = T1.T03ESucDir,
T.T03ESucFax = T1.T03ESucFax,
T.T03ESucTel = T1.T03ESucTel,
T.T03ESucMun = T1.T03ESucMun,
T.T03TviCod = T1.T03TviCod,
T.T03SalBas = T1.T03SalBas
FROM TEM003 T INNER JOIN
TEM003 T1 ON
T.T03TdiCab = T1.T03AfiTdiC AND
T.T03IdeCab = T1.T03AfiIde
Update TEM003
Set T03VSEMCER=(CASE WHEN T03SEMCER >0 THEN T03SEMCER ELSE T03SEMCSIS
END),
T03VSEMCAP(CASE WHEN T03AFIFECU >getdate() THEN 0
ELSE
(CASE WHEN T03SEMCAPB >0 THEN T03SEMCAPB
ELSE(CASE WHEN T03AFIEST<5 THEN
((datediff(DAY,T03Afifeca,getdate()))/7)
ELSE ((DATEDIFF(DAY,T03afifeca,T03afifecr))/7)
END)
END)
END),
T03VSEMTOT(CASE WHEN T03SEMCER >0 THEN T03SEMCER ELSE T03SEMCSIS END)+
(CASE WHEN T03AFIFECU >getdate() THEN 0
ELSE
(CASE WHEN T03SEMCAPB >0 THEN T03SEMCAPB
ELSE(CASE WHEN T03AFIEST<5 THEN
((datediff(DAY,T03afifeca,getdate()))/7)
ELSE ((DATEDIFF(DAY,T03afifeca,T03afifecr))/7)
END)
END)
END)
from TEM003 (nolock fastfirstrow)
suspensión
UPDATE dbo.TEM003
SET T03TnaCod = 'NA', T03CreCod = 'NA'
WHERE (T03AfiEst <> '3')
UPDATE dbo.TEM003
SET T03COTTIP = '9', T03DIRRES = 'NA', T03TELRES = 'NA', T03MUNCRES 'NA'
FROM dbo.TEM003
WHERE T03DIRRES IS NULL
UPDATE dbo.TEM003
SET T03EMPTDI = 'NA', T03EMPIDE = 'NA', T03ESUCCOD = 'NA', T03ESUCNOM
= 'NA',
T03ESUCDIR = 'NA', T03ESUCFAX = 'NA', T03ESUCTEL = 'NA',
T03ESUCMUN = 'NA',
T03TVICOD = 'NA', T03SALBAS = 0
FROM dbo.TEM003
WHERE T03EMPIDE IS NULL
UPDATE dbo.TEM003
SET T03IPSCOD = 'NA', T03SIPCOD = 'NA', T03SIPNOM = 'NA'
FROM dbo.TEM003
WHERE T03IPSCOD IS NULL
Insert Into TemTe4(Te4Cod, Te4Reg)
SELECT Cast(T03Secuenc as Char(8)), rtrim(T03FecStm) +
';' + rtrim(T03FecAfi) + ';' +
rtrim(T03ApePri) + ';' + rtrim(T03ApeSeg) +
';' +
rtrim(T03NomPri) + ' ' + rtrim(T03NomSeg) +
';' +
rtrim(T03AfiIde) + ';' + rtrim(T03AfiTdiC) +
';' +
rtrim(T03FecNac) + ';' + (CASE T03AfiTip
WHEN '1' THEN 'Cot'
WHEN '2' THEN 'Ben'
WHEN '3' THEN 'B/C'
WHEN '4' THEN 'Adi'
WHEN '5' THEN 'Cab'
WHEN '6' THEN 'Sus'
WHEN '7' THEN 'Tut'
ELSE 'NDE'
END)+ ';' +
rtrim(T03Sex) + ';' + rtrim(T03ParCod) +
';' +
rtrim(T03DirRes) + ';' + rtrim(T03TelRes) +
';' +
rtrim(T03MunCRes) + ';' + rtrim(T03MunCAtE) +
';' +
rtrim(T03MunNAte) + ';' + rtrim(T03EmpTdi) +
';' +
rtrim(T03EmpIde) + ';' + rtrim(T03ESucCod) +
';' +
rtrim(T03ESucNom) + ';' + (CASE T03AfiEst
WHEN '1' THEN 'Act'
WHEN '3' THEN 'Sus'
WHEN '5' THEN 'Pro'
WHEN '7' THEN 'Ret'
WHEN '8' THEN 'Por'
WHEN '9' THEN 'Ina'
ELSE 'NA '
END)+ ';' +
rtrim(T03RANSAL) + ';' +
rtrim(T03TfuCod) + ';' +
RTRIM(CONVERT(CHAR(10),T03FuiNum))+ ';'+
rtrim(T03IpsCod) + ';' + rtrim(T03SipCod)
+ ';'+
rtrim(T03SipNom) + ';' + rtrim(T03FecGra)
+ ';'+
(CASE T03CafCod
WHEN '01' THEN 'OA'
WHEN '02' THEN 'NU'
WHEN '03' THEN 'CR'
WHEN '04' THEN 'NA'
WHEN 'CO' THEN 'CO'
ELSE 'ND'
END)+ ';' +
rtrim(T03ApbCAnt) + ';' +
rtrim(T03TdiCab) + ';' + rtrim(T03IdeCab) + ';'+
rtrim(CONVERT(CHAR(20),T03VSEMTOT))+';' +
rtrim(CONVERT(CHAR(20),T03SalBas))+ ';' +
rtrim(T03AseCod) + ';' + rtrim(T03FecIPos) + ';'+
rtrim(T03FecFSer) + ';' + rtrim(T03ESucDir)
+ ';'+
rtrim(T03ESucFax) + ';' + rtrim(T03ESucTel)
+ ';'+
rtrim(T03ESucMun) + ';' + rtrim(T03CotTip)
+ ';'+
rtrim(T03TviCod) + ';' + rtrim(T03FecUAfi)
+ ';'+
rtrim(T03FecAct) + ';' + rtrim(T03TipDis)
+ ';'+
rtrim(T03Zon) + ';' + rtrim(T03TdiCon)
+ ';'+
rtrim(T03IdeCon) + ';' + rtrim(T03TnaCod)
+ ';'+
rtrim(T03CreCod) + ';' + rtrim(T03IndEsp)
+ ';'+
rtrim(T03UsuCod)
From TEM003
Preguntas similare
Busqueda sugerida
Leer las respuestas