Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I must make a view which triggers an executable, retrieves the exe results and displays the results. I really don't care which architecture I use.I figure it can be View => TVF => EXE, but maybe I'm not thinking outside the box enough.The EXE can pipe XML to a temp file; the text file can be bulked back into a variable with
--READ THE XML FILE INTO A VARIABLESELECT @X = CAST(BULKCOLUMN AS XML) FROM OPENROWSET ( BULK '%temp%\Super_TVF.xml' ,SINGLE_BLOB ) AS XMLDATA;
I can parse the XML from there into a nice output of my choice. That all works just fine.However, the TVF cannot launch the EXE with the following statement because of an error:INSERT INTO @RetTable EXECUTE @iRet = XP_CMDSHELL @CMD;Msg 443, Level 16, State 14, Procedure Super_TVF, Line 34Invalid use of a side-effecting operator 'INSERT EXEC' within a function.Any creative twisted minds out there who would care to give me a workaround?~ Shaun MerrillSeattle area
Well, I still need to base a report off of it, which means I need a view to do the launching.Do you recommend I try something like this?
create view dbo.Super_View ASBEGIN IF OBJECT_ID('tempdb.dbo.#JobInfo') IS NOT NULL DROP TABLE #JobInfo SELECT * INTO #JobInfo FROM OPENROWSET('SQLNCLI', 'server=(local);trusted_connection=yes', 'set fmtonly off exec msdb.dbo.sp_help_job') END