13.07.2015 Views

Caché Transact-SQL (TSQL) Migration Guide - InterSystems ...

Caché Transact-SQL (TSQL) Migration Guide - InterSystems ...

Caché Transact-SQL (TSQL) Migration Guide - InterSystems ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Query Statements• OPTION• WITH CUBE• WITH ROLLUP• GROUP BY ALL• GROUP WITH• TOP nn PERCENT or TOP WITH TIES.TOP nn specifies the number of rows to retrieve. <strong>Caché</strong> T<strong>SQL</strong> supports TOP nn with a integer, ?, local variable, or thekeyword ALL. The TOP argument can be enclosed in parentheses TOP (nn). If SET ROWCOUNT specifies fewer rowsthan TOP nn, the SET ROWCOUNT value is used.Table hints are supported with either of the following syntactic forms:FROM tablename (INDEX=indexname)FROM tablename INDEX (indexname)Table hints can be optionally preceded by the WITH keyword, and optionally enclosed in parentheses. A list of table hintscan be separated by either commas or blank spaces. The following table hints are parsed but ignored: FASTFIRSTROW,HOLDINDEX, NOLOCK, PAGLOCK, READCOMMITTED, READPAST, READUNCOMMITTED, REPEAT-ABLEREAD, ROWLOCK, SERIALIZABLE, SHARED, TABLOCK, TABLOCKX, UPDLOCK, XLOCK.SELECT * is supported. The asterisk means to select all columns in the specified table. You can qualify the asterisk withthe table name or table alias: SELECT mytable.*.A SELECT query can contain a subquery in its select list.A Select List can contain stream fields. A SELECT on a stream field returns the oref (object reference) of the openedstream object.A T<strong>SQL</strong> SELECT does not require a FROM clause. A SELECT without a FROM clause can be used to assign a value toa local variable, as follows:DECLARE @myvar INTSELECT @myvar=1234PRINT @myvarAn ORDER BY clause can specify ascending (ASC) or descending (DESC) order. The default is ascending. Unlike <strong>Caché</strong><strong>SQL</strong>, an ORDER BY may be used in subqueries and in queries that appear in expressions. For example:SET @var = (SELECT TOP 1 name FROM mytable ORDER BY name)An INTO clause can be used to select values into a table. This table can be a permanent table, or a temporary table, asshown in the following example:SELECT name,age INTO #MyTemp FROM Sample.PersonSELECT name,age FROM #MyTemp WHERE name LIKE '[A-D]%'If the INTO table does not already exist, SELECT creates it.An INTO clause cannot be used when the SELECT is a subquery or is part of a UNION.A WHERE clause can use AND, OR, and NOT logic keywords. It can group multiple search conditions using parentheses.The WHERE clause supports the following search conditions:• Equality comparisons: = (equals), (not equals), < (less than). > (greater than), = (greaterthan or equals)• IS NULL and IS NOT NULL comparisons<strong>Caché</strong> <strong>Transact</strong>-<strong>SQL</strong> (T<strong>SQL</strong>) <strong>Migration</strong> <strong>Guide</strong> 23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!