select ' if (!reader.IsDBNull(reader.GetOrdinal("'+ col.NAME+'")))'
+ ' {'
+ ' item.'+col.NAME +' = reader.GetString(reader.GetOrdinal("'+ col.NAME+'"));'
+ ' }'
+ ' else'
+ ' {'
+ ' item.'+ col.NAME+' = "";'
+ ' }'
FROM dbo.syscolumns col
inner JOIN dbo.sysobjects obj ON col.id = obj.id
AND obj.xtype = 'U'
AND obj.status >= 0
WHERE obj.name = 'PCGS_Equipment'--表名
ORDER BY col.colorder