0

I use openrowset to execute OperatorsCalc procedure.

How can I send declared parameters:

  1. @operators (OperatorTableType)

  2. @number (int)

into procedure that is executed by openrowset?

DECLARE @operators OperatorTableType
insert into @operators values ('Mr James')
insert into @operators values ('Mr Johnny')

DECLARE @number int = 3

SELECT *
INTO #MyTempTableForOperators
FROM
    OPENROWSET('SQLNCLI', 'Server=apollo;Trusted_Connection=yes;',
               'SET FMTONLY OFF; 
                SET NOCOUNT ON; 
                EXEC servername.dbname.dbo.OperatorsCalc @number @operators') -- I want to sent parameters @operators and @number in here

select * from #MyTempTableForOperators
2
  • Which dbms product is this for? (Doesn't look like ANSI SQL.) Commented Aug 26, 2015 at 15:36
  • microsoft sql server 2008 Commented Aug 29, 2015 at 5:57

1 Answer 1

1

Try to use linked server, but it may fail if there is nested insert into temp.

CREATE TABLE #temp (...)

INSERT INTO #temp(...)
EXECUTE [servername].[dbname].[dbo].[OperatorsCalc] @number @operators;

Read also How to Share Data between Stored Procedures by Erland Sommarskog. There is good chapter about OPENQUERY.

Sign up to request clarification or add additional context in comments.

1 Comment

it worked, thank you also for those links, they are sooooo usefull

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.