User defined function + Openquery + sp_executesql

Posted: May 10, 2011 in SQLServer
Tags: ,
  • User-defined function calls inside a four-part linked server query in case if it is not supported
    • Ex: Select * from Linked_Server.northwind.dbo.square_value(10)
  • Use Openquery function …
    • Ex: Select * from Openquery(Linked_Server,’select northwind.dbo.square_ value(10)’)
  • If the user-defined function takes variable or scalar parameters, you can use the sp_executesql stored procedure
    • exec Linked_Server.northwind.dbo.sp_executesql N’SELECT northwind.dbo.square_value(@input)’,N’@input int’,@input=10



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s