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
Add Comment
Please, Sign In to add comment