Query Syntax
Version 22.0.8486
Version 22.0.8486
Query Syntax
You can execute SQL-92 queries against your connections just as you would query a physical SQL Server database.
Select Statements
The following syntax diagram outlines the syntax supported by the SQL engine of the driver:
SELECT {
[ TOP <numeric_literal> | DISTINCT ]
{
*
| {
<expression> [ [ AS ] <column_reference> ]
| { <table_name> | <correlation_name> } .*
} [ , ... ]
}
[ INTO csv:// [ filename= ] <file_path> [ ;delimiter=tab ] ]
{
FROM <table_reference> [ [ AS ] <identifier> ]
} [ , ... ]
[ [
INNER | { { LEFT | RIGHT | FULL } [ OUTER ] }
] JOIN <table_reference> [ ON <search_condition> ] [ [ AS ] <identifier> ]
] [ ... ]
[ WHERE <search_condition> ]
[ GROUP BY <column_reference> [ , ... ]
[ HAVING <search_condition> ]
[ UNION [ ALL ] <select_statement> ]
[
ORDER BY
<column_reference> [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]
]
[
LIMIT <expression>
[
{ OFFSET | , }
<expression>
]
]
} | SCOPE_IDENTITY()
<expression> ::=
| <column_reference>
| @ <parameter>
| ?
| COUNT( * | { [ DISTINCT ] <expression> } )k
| { AVG | MAX | MIN | SUM | COUNT } ( <expression> )
| NULLIF ( <expression> , <expression> )
| COALESCE ( <expression> , ... )
| CASE <expression>
WHEN { <expression> | <search_condition> } THEN { <expression> | NULL } [ ... ]
[ ELSE { <expression> | NULL } ]
END
| <literal>
| <sql_function>
<search_condition> ::=
{
<expression> { = | > | < | >= | <= | <> | != |
LIKE | NOT_LIKE | IN | NOT_IN | IS_NULL | IS_NOT_NULL |
AND | OR | CONTAINS | BETWEEN
} [ <expression> ]
} [ { AND | OR } ... ]
Insert Statements
The INSERT statement specifies the columns to be inserted and the new column values. You can specify the column values in a comma-separated list in the VALUES clause:
INSERT INTO <table_name>
( <column_reference> [ , ... ] )
VALUES
( { <expression> | NULL } [ , ... ] )
<expression> ::=
| @ <parameter>
| ?
| <literal>
Update Statements
The UPDATE statement takes as input a comma-separated list of columns and new column values as name-value pairs in the SET clause
UPDATE
<table_name>
SET
{ <column_reference> = <expression> } [ , ... ]
WHERE
Id = <expression> } [ { AND | OR } ... ]
<expression> ::=
| @ <parameter>
| ?
| <literal>
Delete Statements
The DELETE statement requires the table name in the FROM clause and the row’s primary key in the WHERE clause.
DELETE FROM <table_name>
WHERE {
Id = <expression>
} [ { AND | OR } ... ]
<expression> ::=
| @ <parameter>
| ?
| <literal>
Execute Statements
The EXECUTE Statement allows you to run procedures.
{ EXECUTE | EXEC } <proc_name>
{
[ @ ] <input_name> = <expression>
} [ , ... ]
<expression> ::=
| @ <parameter>
| ?
| <literal>