The TABLESAMPLE clause can only be used with local tables.

Error Message:
Msg 494, Level 16, State 1, Line 4
The TABLESAMPLE clause can only be used with local tables.

Severity level:
16.

Description:
This error message appears when you try to use the TABLESAMPLE clause with a non-local table.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Errors of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. The TABLESAMPLE clause can only be used with local tables.

Versions:
This error message was introduced with SQL Server 2005.

Example(s):
DECLARE @f int;

SET @f = 100;
SELECT
    *
FROM
    INFORMATION_SCHEMA.TABLES TABLESAMPLE (@f ROWS);

Remarks:
In the above example we try to use the TABLESAMPLE clause for the INFORMATION_SCHEMA.TABLES view. This raises the error.

]]>

Leave a comment

Your email address will not be published.