After many years of trying to work SQLServer into my daily life, I've finally got a project that I can use it. Of course, I still need to attach back to the Informix database where most of my data resides. The following code snippet allows SQLServer to pass a preformatted query through to Informix as a Linked Server.
USE [Dispatch]
GO
/****** Object: StoredProcedure [dbo].[ExecOpenQuery] Script Date: 09/11/2007 08:47:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ExecOpenQuery] (
@TSQL varchar(8000)
)
AS
SET NOCOUNT ON
-- Build OpenQuery command
DECLARE @OpenQuery varchar(4000)
SET @OpenQuery = 'SELECT * FROM OPENQUERY(IfxVisops, '''
-- Display Dynamic SQL
print @OpenQuery + @TSQL
-- Execute SQL
exec(@OpenQuery + @TSQL)
RETURN
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment