开发者

Is there a way to prevent SQL Server from Validating the SQL in a stored procedure during CREATE / ALTER

One aspect of our system requires our SQL Server instance to talk to a MySQL Server via a linked Server Connection.

MSSQL -> LinkedServer(MSDASQL ODBC Provider) -> MySQL ODBC Connector -> MySQL DB

The Table on the linked server is called in a SPROC along the lines of

CREATE PROCEDURE DoStuff
AS

SELECT a.ID, a.Name, b.OtherProperty
FROM   MyDatabase..MyTable a
JOIN   LINKSRVR...OtherTable b
ON     a.ID = b.ID

GO

The problem is that the MySQL database lives on another network, only accessible by VPN & that the CREATE or ALTER statement breaks with the following error unless the VPN is active.

The OLE DB provider "MSDASQL" for linked server "LINKSRVR" reported an error. 
 The provider did not give any information about the err开发者_C百科or.

Cannot initialize the data source object of OLE DB provider 
"MSDASQL" for linked server "LINKSRVR".

Is there anyway to force SQL Server to just go ahead and create the SPROC with the SQL I tell it and not to try and validate if the LinkedServer is up/down.


You'd have to "hide" the offending SQL from the compiler by placing it in a string and executing it as dynamic SQL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜