Use SQL syscolumns to query table fields and splice the code, sqlsyscolumns
We cannot avoid adding or updating data when writing code. However, if there are too many fields in a table, the amount of code to be written will increase. For example, we can concatenate an Insert SQL statement with StringBuilder;
You can use the code generator to generate this non-technical code, or use SQL to generate it based on the table fields:
1. the following code finds the names of all fields in a table.
Select Name From syscolumns where id = OBJECT_ID ('table name ')
2. On the basis of 1, we can splice our returned results at will. For example, we need to splice all fields with commas (, of course, we can implement this through SQL recursion, however, if you no longer make logical judgments on the results, you can try the following method to make it faster)
First run the select Name + ',' From syscolumns where id = OBJECT_ID ('table name') statement execution result, and then copy the entire column value to EditPlus, you can obtain a string after merging.
3. Based on the 2nd-step idea, we can splice and use it as needed.
Select '_ InsertSQL. append (",'' "+ _ k3dt. rows [I] ["'+ name +'"]. toString () + "'' "); 'from syscolumns where id = OBJECT_ID ('t _ ICItem ')