u can add something variable in Openrowset to provide "Provider", "Connection", "Query"
use something like this
where the @Connectionstring are
use something like this
DECLARE @Query NVARCHAR(4000)
SET @Query =
'SELECT ''Please Select'' AS [Department]
UNION ALL
SELECT [Department]
FROM OPENROWSET(
''SQLNCLI'',
''' + @ConnectionString + ''',
''EXEC SPROC_NAME_HERE'')
EXEC (@Query)
where the @Connectionstring are
Server=SERVER_NAME\INSTANCE_NAME;UID=USER_ID;PWD=PASSWORD;Database=DATABASE;'
Comments