Home > Software engineering >  Rookie inquire a data problem to be obtained
Rookie inquire a data problem to be obtained

Time:10-06

Each prawn, I have a table in the database, the question now is what command can get such a data: carid: license plate, remark: temporary car or VIP, time: park total duration (time reduction approach time) add: address; Because my level is limited, please expert help, solve steps as far as possible detailed
Dbo. Re
Carid remark time add
Sichuan A0D3U7 temporary car 2016/11/6 14:05:14 Kim cross the entrance 1
Sichuan A0D3U7 temporary car 2016/11/6 14:43:45 moganshan export
Sichuan A0M2M3 temporary car 2016/11/11 17:48:53 moganshan entry
Sichuan A0M2M3 temporary car 2016/11/11 20:10:56 moganshan export
Sichuan A0S953 temporary car 2016/11/5 15:01:39 moganshan export
Sichuan A0Y91Z VIP car 2016/11/1 6:56:20 moganshan export
Sichuan A0Y91Z VIP car 2016/11/1 21:48:01 moganshan entry
Sichuan A0Y91Z VIP car 2016/11/2 6:53:31 moganshan export
Sichuan A0Y91Z VIP car 2016/11/2 21:33:17 moganshan entry
Sichuan A0Y91Z VIP car 2016/11/3 5:04:25 Kim cross the entrance 1
Sichuan A0Y91Z VIP car 2016/11/3 6:54:34 moganshan export
Sichuan A0Y91Z VIP car 2016/11/3 17:40:05 Kim cross the entrance 1

CodePudding user response:

Select select data with SQL statements

CodePudding user response:

reference 1st floor oyljerry response:
select select data using SQL statements
webmaster's adult, can give a detailed statement

CodePudding user response:

ADO database operation

CodePudding user response:

The select field 1, field 2... From the name of the table

CodePudding user response:

To access and change relation data


The cursor
In a relational database operation will affect the entire row sets, set of rows returned by the SELECT statement includes all of the statements in the WHERE clause condition, returned by the statement that a complete set of line known as the result set, applications, especially interactive online application, do not always to the entire result set as a unit, to effectively deal with these applications require a mechanism so that each dealing with a line or part of the line, the cursor is to provide the mechanism of the result set extensions,

Cursor extension result processing by the following way:

Allowed to locate a particular line in the result set,


From the result set of the current position to retrieve one or more lines,


Support the rows in the result set the current position data modification,


For other users to display the changes in the result set in the database data to provide different levels of visibility support,


Provide script, stored procedures and triggers used in access to Transact - SQL statement of the result set data,
Request a cursor
Microsoft? SQL Server? 2000 supports two ways to request the cursor:

Transact - SQL
Based on SQL - 92 cursor grammar of the cursor, Transact - SQL syntax of language support to use them,

Database application programming interface (API) cursor function
SQL Server supports these database API cursor function:

ADO (Microsoft ActiveX? The data object)


OLE DB


ODBC (open database connectivity)


The DB - Library
Application cannot mix these two request vernier method, have been used API specified CURSOR behavior application cannot perform Transact - SQL DECLARE CURSOR statement requests a Transact - SQL CURSOR, only when all the API CURSOR features are set to the default value, applications can perform DECLARE CURSOR,

If Transact - SQL and API cursor has not been requested, then by default, SQL Server will be a full result sets returned to the application, the result set is called the default result set,

The cursor process
Transact - SQL cursor and API cursor has a different syntax, but the following general process can be used for all SQL Server cursor:

The cursor associated with Transact - SQL statement of the result set, and define the characteristics of the cursor, such as whether to be able to update rows in the cursor,


Perform Transact - SQL statement to fill the cursor,


Retrieve the line, want to see the cursor retrieve one or more rows from your cursor called extraction operation, implement a series of extraction operation to forward or backward retrieval line called rolling operation,


According to the need of the current position of the cursor row modification operations (update, or delete),


Close the cursor,
? 1988-2000 Microsoft Corporation, all rights reserved.

CodePudding user response:

 
To access and change relation data


Transact - SQL cursor
Transact - SQL cursor is mainly used in stored procedures, triggers and Transact - SQL script, they make the content of the result set for other Transact - SQL statement is also available,

Used in the stored procedure or trigger Transact - SQL cursor typical process for:

Statement to Transact - SQL variable contains the cursor returned data, result set columns for each declare a variable, declare variables is large enough to hold the return value of column, and statements can be obtained from the column data type conversion in a recessive manner of data types,


Use the DECLARE CURSOR statement to Transact - SQL CURSOR is associated with a SELECT statement, DECLARE CURSOR statement define the characteristics of the CURSOR at the same time, such as the name of the CURSOR and whether the CURSOR is read-only or only into the characteristics,


Use the OPEN statement execution SELECT statement and generate cursor,


Using the FETCH INTO statements extract a single row, and transfer of data in each column to specify variables, then other Transact - SQL statement to refer to these variables to access has been extracted data values, Transact - SQL does not support line extraction block,


The end of the cursor, use the CLOSE statement, CLOSE the cursor can release some resources, such as the cursor result set and the current row locking, but if you want to send a OPEN statement, then the cursor structure can still be used for processing, because the cursor still exists, at this point is not to use the name of the cursor, DEALLOCATE statement is released in full assigned to the resources of the cursor, including the name of the cursor, the cursor is released, must use the DECLARE statement to regenerate the cursor,
Monitor Transact - SQL cursor activity
Can use sp_cursor_list system stored procedure to get the current connection visible cursor list, use sp_describe_cursor, sp_describe_cursor_columns and sp_describe_cursor_tables to determine the characteristics of the cursor,

After the cursor open @ @ CURSOR_ROWS function or by sp_cursor_list or sp_describe_cursor returned CURSOR_ROWS column will point out the rows in the cursor,

After each FETCH statement execution, @ @ FETCH_STATUS updated to reflect the final state of extraction, also can return from the sp_describe_cursor FETCH_STATUS column to get the state information, @ @ FETCH_STATUS report cursor in the state, such as beyond the first line and last line extraction, @ @ FETCH_STATUS for connection is global, and connection cursor open by each extract reset, if you have to understand the status in the future, you need to perform another statement in connection, before the @ @ FETCH_STATUS stored in a user variables, even if the next statement is not FETCH, also may be INSERT, UPDATE or DELETE those statements, which can trigger contains reset @ @ FETCH_STATUS FETCH statement triggers, sp_describe_cursor returned FETCH_STATUS column to specify cursor is certain, not affected by the reference to other cursor FETCH statement, but sp_describe_cursor will FETCH statement by reference to the same cursor, so must pay attention to when using,

After completion OF the FETCH cursor will locate in the line, the extracted line called the CURRENT line, if there is no statement as read-only cursor cursor, you can perform with the WHERE the CURRENT OF cursor_name clause OF the UPDATE or DELETE statement to modify the CURRENT line,

By DECLARE CURSOR Transact - SQL statement given the name of the CURSOR can be global or local, global the name of the CURSOR is located on the same connection can be made of any the batch, stored procedure or trigger references, the local name of the CURSOR cannot be declared CURSOR batch, stored procedure or trigger is referenced, triggers and stored procedures in the local cursors and thus can avoid unintentional references from external stored procedures or triggers,

Use cursor variable
Microsoft? SQL Server? 2000 also support the cursor variable data type, the cursor can have two kinds of method that is associated with a cursor variable:

/* Use DECLARE @ local_variable, DECLARE CURSOR and SET. */
DECLARE @ MyVariable CURSOR

DECLARE MyCursor CURSOR FOR
The SELECT LastName FROM Northwind. Dbo. Employees

The SET @ MyVariable=MyCursor

/* Use DECLARE @ local_variable and SET */
DECLARE @ MyVariable CURSOR

The SET @ MyVariable=CURSOR SCROLL KEYSET FOR
The SELECT LastName FROM Northwind. Dbo. Employees

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related