Sql updating a query result set

6854933580_2c8b688306_z

As a result, some of the data in the destination fields may be truncated (deleted).

The section Restrictions on data type conversions lists the ways in which you can and cannot convert data types.

The QSql Query Model and QSql Table Model classes described in the next section provide a higher-level interface for accessing databases.

TOP ( ) Specifies one or more table hints that are allowed for a target table. @ When referencing the Unicode character data types nchar, nvarchar, and ntext, 'expression' should be prefixed with the capital letter ' N'.

If ' N' is not specified, SQL Server converts the string to the code page that corresponds to the default collation of the database or column.

It is not uncommon to have stored procedures returning result sets, and although it sounds like a good idea, it becomes a problem when you want to have control of the name of the columns and data type of the columns being returned as part of the result set.

SQL Server 2012 (Code name SQL Denali) introduces a new feature WITH RESULT SETS which lets you redefine the name and data types of the columns being returned from the stored procedure.

This comes in very handy when you want to insert the records coming in a result set to a temporary table with a specific column name and data type and you don’t want to rely on what is being returned by the stored procedure.

The WITH RESULT SETS clause can also be used with a stored procedure, which returns multiple result sets and for each result set you can define the column name and data types for each column separately.

When you need to update data from one table to another, consider the following rule: the data types for the source and destination fields must either match or be compatible.

Furthermore, when you update data from one table to another and use compatible data types instead of matching data types, Access converts the data types of those fields in the destination table.

If you are unfamiliar with SQL, you might want to skip directly to the next section (Using the SQL Model Classes).

To execute an SQL statement, simply create a QSql Query object and call QSql Query::exec() like this: The QSql Query constructor accepts an optional QSql Database object that specifies which database connection to use.

You must have an account to comment. Please register or login here!