July 9, 2018 at 7:12 am
declare @Tmp as varchar(25)
set @Tmp ='ΠΑΠΑΓΟΥ'
SELECT
*
INTO
#tmpSortedBooks
FROM
OPENROWSET(
'SQLNCLI',
'Server=MNG01\MPISDARIS;Trusted_Connection=yes;Database=Reporting;',
'EXEC dbo.papagos1 '@tmp)
I WOULD LIKE TO EXECUTE A STORED PROCEDURE which has a dynamic parameter ? which is the correct syntax to run this code..?
July 9, 2018 at 7:55 am
george.sofroniadis - Monday, July 9, 2018 7:12 AMdeclare @Tmp as varchar(25)
set @Tmp ='ΠΑΠΑΓΟΥ'
SELECT
*
INTO
#tmpSortedBooks
FROM
OPENROWSET(
'SQLNCLI',
'Server=MNG01\MPISDARIS;Trusted_Connection=yes;Database=Reporting;',
'EXEC dbo.papagos1 '@tmp)
I WOULD LIKE TO EXECUTE A STORED PROCEDURE which has a dynamic parameter ? which is the correct syntax to run this code..?
OPENROWSET cannot take parameters. You'll have to materialize the command using dynamic SQL observing, of course, the proper methods to avoid SQL Injection.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 11, 2018 at 6:03 am
Hi George,
One way of achieving this would be to create and define your temp table first and the insert into from the proc, for example -
declare @Tmp as varchar(25)
set @Tmp ='????G??'
CREATE TABLE #tmpSortedBooks
(
ColumnA <DATATYPE>
,ColumnB <DATATYPE>
,ColumnC <DATATYPE>
)
INSERT INTO #tmpSortedBooks
EXEC [Reporting].dbo.papagos1 @Tmp
SELECT *
FROM #tmpSortedBooks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply