January 18, 2013 at 1:34 pm
Hello,
I have a sp where I created a temp table, I need then insert the result of another sp into that table.
I end up write code like this:
set @sql = '
Insert into #BreakDownByCategories
Select * FROM OPENROWSET( ' + '''' + 'SQLNCLI' + '''' + ',' + '''' +
'Server=(local);Trusted_Connection=yes;' + '''' + ',' + '''' +
'SET FMTONLY OFF; SET NOCOUNT ON; exec spGetCategoriesByDocIDAsTable ' + Convert(varchar, @DocID) + '''' + ')'
exec (@sql )
I wonder if there is a better way to do this since OPENROWSET is usually disabled.
Thank you.
January 18, 2013 at 2:40 pm
INSERT INTO #BreakDownByCategories
EXEC dbo.spGetCategoriesByDocIDAsTable @DocID
--Jeff Moden
Change is inevitable... Change for the better is not.
January 18, 2013 at 2:45 pm
Jeff Moden (1/18/2013)
INSERT INTO #BreakDownByCategoriesEXEC dbo.exec spGetCategoriesByDocIDAsTable @DocID
I believe an accidental typo?
INSERT INTO #BreakDownByCategories
EXEC dbo.spGetCategoriesByDocIDAsTable @DocID
______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience
January 18, 2013 at 2:53 pm
MyDoggieJessie (1/18/2013)
Jeff Moden (1/18/2013)
INSERT INTO #BreakDownByCategoriesEXEC dbo.exec spGetCategoriesByDocIDAsTable @DocID
I believe an accidental typo?
INSERT INTO #BreakDownByCategories
EXEC dbo.spGetCategoriesByDocIDAsTable @DocID
Thanks for the catch. You are correct.... the second "exec" should not have been there. Was a Copy/Paste error on my part.
Repaired my post.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 18, 2013 at 3:00 pm
Jeff Moden (1/18/2013)
INSERT INTO #BreakDownByCategoriesEXEC dbo.spGetCategoriesByDocIDAsTable @DocID
Jared
CE - Microsoft
January 21, 2013 at 8:34 am
Thank you all for the replies
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply