(1) data record filter :
Sql= "SELECT * from data table where field name = field value order BY field name [desc]"
Sql= "SELECT * from data table where field name like '% field value% ' Order by field name [desc]"
Sql= "SELECT Top ten * from data table where field name order by field name [desc]"
Sql= "SELECT * from data table where field name in (' Value 1 ', ' Value 2 ', ' Value 3 ')"
Sql= "SELECT * from data table where field name between value 1 and value 2"
(2) update data record :
sql= "Update data table set field name = field value where Condition expression"
sql= "Update data Table set field 1= value 1, field 2= value 2 ... field n= value n Where Condition expression "
(3) Delete data record :
Sql= "Delete from data table where conditional expression"
Sql= "Delete from data table" (delete all records of the datasheet)
(4) add data record :
Sql= "INSERT into Data table (field 1, Field 2, Field 3 ...) Values (value 1, value 2, value 3 ...) "
Sql= "INSERT INTO Target data table select * From source data table" (Add records from source data table to target datasheet)
(5) data record statistic function :
AVG (field name) results in a table bar average
Count (*¦ field name) statistics on the number of data rows or the number of rows with values for a column
Max (field name) gets the maximum value of a table column
Min (field name) gets the lowest value of a table bar
sum (field name) adds the value of the data bar
Methods that refer to the above functions:
Sql= "Select sum (field name) as Alias from data table where conditional expression"
Set Rs=conn.excute (SQL)
Use RS ("Alias") to obtain the value of the system, the other functions used ibid.
(6) Creation and deletion of data sheets:
CREATE table Data table name (field 1 type 1 (length), Field 2 type 2 (length) ...)
Example: CreateTable tab01 (name varchar), datetime default Now ())
drop table data table name (permanently delete a data table)
Methods for Recordset objects :
Rs.movenext Moves the record pointer down one line from the current position
rs.moveprevious Moves the record pointer up one line from the current position
Rs.movefirst Move the record pointer to the first row of the data table
Rs.movelast Move the record pointer to the last row of the data table
rs.absoluteposition=n Move the record pointer to the nth row of the data table
rs.absolutepage=n Move the record pointer to the first row of page N
rs.pagesize=n set to N records per page
Rs.pagecount Returns the total number of pages based on pagesize settings
Rs.recordcount Returns the total number of records
Rs.bof Returns whether the record pointer is above the first end of the data table, True indicates Yes, False no
rs.eof Returns whether the record pointer is outside the end of the data table, True indicates Yes, False no
rs.delete Deletes the current record, but the record pointer does not move down
rs.addnew Adding records to the end of the data table
rs.update Updating data sheet Records
How to use SQL Server common commands