Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim rs AS NEW ADODB.Recordset
- 'Saber el tipo de columna
- sqlLee = "SELECT " & _
- "R.RDB$FIELD_NAME AS NombreColumna, " & _
- "F.RDB$FIELD_TYPE As TipoCodCol " & _
- "From RDB$RELATION_FIELDS R " & _
- "Left Join " & _
- "RDB$FIELDS F ON R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME " & _
- "where " & _
- "R.RDB$RELATION_NAME='SCFB' AND R.RDB$FIELD_NAME = 'SCFB_SER' "
- rs.Open sqlLee, dB, 1, 1
- If rs!TipoCodCol = 8 Then 'Cambiando nombre
- dB.BeginTrans
- sqlCambia = "Alter Table SCFB Alter Column SCFB_SER TO SCFB_SER2"
- dB.EXECUTE sqlCambia, , adCmdText
- sqlAgrega = "Alter Table SCFB Add SCFB_SER_NEW VARCHAR(4)"
- dB.EXECUTE sqlAgrega, , adCmdText
- dB.CommitTrans
- dB.BeginTrans
- sqlMueve = "Update SCFB SET SCFB_SER_NEW = Cast(SCFB_SER2 as VARCHAR(4)) where SCFB_SER2 IS NOT NULL"
- dB.EXECUTE sqlMueve, , adCmdText
- dB.CommitTrans
- dB.BeginTrans
- selBorrar = "ALTER TABLE SCFB DROP SCFB_SER2"
- dB.EXECUTE selBorrar, , adCmdText
- dB.CommitTrans
- dB.BeginTrans
- sqlCambia = "ALTER TABLE SCFB ALTER COLUMN SCFB_SER_NEW TO SCFB_SER"
- dB.EXECUTE sqlCambia, , adCmdText
- sqlPosic = "Alter Table SCFB Alter SCFB_SER Position 5"
- dB.EXECUTE sqlPosic, , adCmdText
- dB.CommitTrans
- END IF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement