当前位置: 代码迷 >> VFP >> 删除空字段解决方案
  详细解决方案

删除空字段解决方案

热度:5904   发布时间:2013-02-26 00:00:00.0
删除空字段
有一个表有姓名、性别、成绩、班级等,若表中有记录均为空的字段,请问怎样判断,用代码又怎样将其删除呢?如所有记录中性别没有录入,怎样将性别这个字段从表中删除呢?

------解决方案--------------------------------------------------------
测-试OK,如果当前字段中,有记录为空或NULL,则删除该列。
参考:
SQL code
*测-试-环-境:VFP 8.0Close TablesUse "e:\book1.dbf" Alias t_TestSelect t_TestgnFieldcount = Afields(aArray_Fields, "t_Test") && 创建数组For nCount = 1 TO gnFieldcount       cField_Name = aArray_Fields(nCount, 1)  &&取当前字段名          Select 0     Select t_Test.* from t_Test where &cField_Name is null or Empty(&cField_Name) into cursor c_Result_Temp           *如果该字段中,有记录为空或NULL,则删除该列     If Reccount("c_Result_Temp") = 0          Alter Table t_Test drop COLUMN &cField_Name      Endif            use in c_Result_tempEndfor
  相关解决方案