Tuesday 19 June 2012

Remote table-valued function calls are not allowed

 Remote table-valued function calls are not allowed. Msg 4122, Level 16, State 1, Line 1.

     I was doing some task and found the said error. I googled and found that this error may come in different cases, for two cases I have seen are .. 

 1) First case comes when you are calling a table from remote server, but at the same time you are giving a (NOLOCK) Hint. For an example See below :


SELECT * FROM [50.15.250.70].BSE.DBO.EmployeeMaster (NOLOCK)
----- And the output is : ------ 
Msg  4122, Level 16, State 1, Line 1 Remote table-valued function calls are not allowed.



 THIS CAN BE AVOIDED BY ADDING 'WITH' BEFORE (NOLOCK) HINT, SEE BELOW :


SELECT * FROM [50.15.250.70].BSE.DBO.EmployeeMaster WITH (NOLOCK)
  ----- And the output is : ------  
EmpID EmpName     Address     ContactNo
U001  Joseph      UK          2222222222
U002  Anil        India       5555555555
U003  Bruce       China       3333333333
U004  Simmy       Canada      4444444444
……..  ……          …….         …….




2) Second case comes when you are calling a table valued function from the Remote Server using liked server, see below :


SELECT * FROM [50.15.250.70].BSE.DBO.tvf_TestFunction()
----- And the output is : ------ 
Msg  4122, Level 16, State 1, Line 1 Remote table-valued function calls are not allowed.



    This is because in MSSQL Server, calling a remote table valued function is not supported..





Reference: Govind Badkur(http://govindbadkur.blogspot.com)

7 comments: