Advertisement
YAcosta

Untitled

Dec 6th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.25 KB | None | 0 0
  1. Dim rs AS NEW ADODB.Recordset
  2. 'Saber el tipo de columna
  3. sqlLee = "SELECT " & _
  4.   "R.RDB$FIELD_NAME  AS NombreColumna, " & _
  5.   "F.RDB$FIELD_TYPE  As TipoCodCol " & _
  6. "From RDB$RELATION_FIELDS R " & _
  7. "Left Join " & _
  8.   "RDB$FIELDS F ON R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME " & _
  9. "where " & _
  10.   "R.RDB$RELATION_NAME='SCFB' AND R.RDB$FIELD_NAME = 'SCFB_SER' "
  11. rs.Open sqlLee, dB, 1, 1
  12. If rs!TipoCodCol = 8 Then     'Cambiando nombre
  13.    dB.BeginTrans
  14.    sqlCambia = "Alter Table SCFB Alter Column SCFB_SER TO SCFB_SER2"
  15.    dB.EXECUTE sqlCambia, , adCmdText
  16.    
  17.    sqlAgrega = "Alter Table SCFB Add SCFB_SER_NEW VARCHAR(4)"
  18.    dB.EXECUTE sqlAgrega, , adCmdText
  19.    dB.CommitTrans
  20.    
  21.    dB.BeginTrans
  22.    sqlMueve = "Update SCFB SET SCFB_SER_NEW = Cast(SCFB_SER2 as VARCHAR(4)) where SCFB_SER2 IS NOT NULL"
  23.    dB.EXECUTE sqlMueve, , adCmdText
  24.    dB.CommitTrans
  25.    
  26.    dB.BeginTrans
  27.    selBorrar = "ALTER TABLE SCFB DROP SCFB_SER2"
  28.    dB.EXECUTE selBorrar, , adCmdText
  29.    dB.CommitTrans
  30.  
  31.    dB.BeginTrans
  32.    sqlCambia = "ALTER TABLE SCFB ALTER COLUMN SCFB_SER_NEW TO SCFB_SER"
  33.    dB.EXECUTE sqlCambia, , adCmdText
  34.    
  35.    sqlPosic = "Alter Table SCFB Alter SCFB_SER Position 5"
  36.    dB.EXECUTE sqlPosic, , adCmdText
  37.    
  38.    dB.CommitTrans
  39. END IF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement