Declare



DECLARE sets a variable to the value of an expression. The variable can then be used, with its @ prefix, in the statements that follow it in the same script.

round-pushpin Declares a number and uses it in a WHERE clause.
DECLARE @Language = 2
SELECT Text FROM WordList:Word WHERE LanguageId = @Language

round-pushpin Declares the result of an expression.
DECLARE @Pattern = 'Cat' + '%'
SELECT Text FROM WordList:Word WHERE Text LIKE @Pattern

round-pushpin Uses a variable in the field list.
DECLARE @Greeting = 'Hello'
SELECT @Greeting + ' ' + Text as Message FROM WordList:Word WHERE Id = 1

Client parameters

Parameters passed by an application through the client API are used the same way, for example WHERE Name = @Name. See Client.




SQL :: Scalar Functions
Scalar functions are evaluated once per row.
SQL :: Session Variables
Settings that are scoped to the connected session.
SQL :: Set
Set changes a session variable.
SQL :: Single
A built-in schema containing exactly one document, used to evaluate constant expressions.
SQL :: Syntax
Basic KBSQL syntax and some examples.
SQL :: TraceWaitTimes
Reports the time spent in each internal operation of a query.
SQL :: Transaction
Transactions make a group of statements all-or-nothing.
SQL :: WarnMissingFields
Warns when a query references a field that a document does not have.
SQL :: WarnNullPropagation
Warns when a null makes an expression null.
SQL :: Where
The where clause filters the documents read, updated or deleted by a statement.