Suppose we have a student table. If
we will execute following sql query in sql server
SELECT * FROM Student(INDEX)
Or
SELECT * FROM Student(NOLOCK,READPAST)
We will get error
nessage :
Parameters
supplied for object '' which is not a function. If the parameters are intended
as a table hint, a WITH keyword is required.
Cause: It is due to either we are using
invalid table hints or we are using table hints without WITH clause.
Solution:
Valid table hints are:
Table Hints
|
NOEXPAND
|
INDEX
|
FORCESCAN
|
FORCESEEK
|
HOLDLOCK
|
NOLOCK
|
NOWAIT
|
PAGLOCK
|
READCOMMITTED
|
READCOMMITTEDLOCK
|
READPAST
|
READUNCOMMITTED
|
REPEATABLEREAD
|
ROWLOCK
|
SERIALIZABLE
|
SPATIAL_WINDOW_MAX_CELLS
|
TABLOCK
|
TABLOCKX
|
UPDLOCK
|
XLOCK
|
Correct ways to write of above queries
are:
SELECT * FROM Student WITH(INDEX = IXNAME)
Or
SELECT * FROM Student WITH(NOLOCK,READPAST)
Or
SELECT * FROM Student (NOLOCK)
No comments:
Post a Comment