2

I am executing the string that contains the below code

DECLARE @BadgeNo NVARCHAR(MAX);
SET @BadgeNo='8107';

SELECT * INTO #Testing 
   EXEC spNotification 'Param1','Param2','Param3','Param4';

EXEC  spSqlTmpTblToHtmlTbl 'tempdb..#Testing'

I just want the result in html format. So I am executing spnotification to get the results.

The spSqlTmpTblToHtmlTbl converts the temp table to table format. But here is an issue that I can't create a temp table from spNotification result. I know

select * into 

command won't work with the exec command. So how can I achieve this?

3
  • change your spNotification to a table value function and then use it Commented Jul 24, 2014 at 5:03
  • stackoverflow.com/questions/653714/… Commented Jul 24, 2014 at 5:03
  • 1
    I already have to Stored Procedure and we are trying to use that stored procedure globally. Incase if we have to make any modification in the logic we have to alter the SP alone. Also function takes much time to compile and execute. Commented Jul 24, 2014 at 5:17

2 Answers 2

3

You probably want to do something like this":

CREATE TABLE #Testing 
(
   COLUMN1 INT,
   COLUMN2 INT
)

INSERT INTO #Testing 
Exec spNotification 'Param1','Param2','Param3','Param4';

Also check How to SELECT * INTO [temp table] FROM [stored procedure]

Or you may try with OPENQUERY:

SELECT  *
INTO    #Testing 
FROM    OPENQUERY(YOURSERVERNAME, 'Exec spNotification 'Param1','Param2','Param3','Param4'')
Sign up to request clarification or add additional context in comments.

1 Comment

spnotification will produce dynamic data.In our environment openQuery has been restricted!
0

Try this:

DECLARE @Testing TABLE 
  ( 
     COLUMN1 INT, 
     COLUMN2 INT 
  ) 

INSERT INTO @Testing 
            (COLUMN1, 
             COLUMN2) 
EXEC SPNOTIFICATION 
  'Param1', 
  'Param2', 
  'Param3', 
  'Param4'; 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.