Can somebody please help me because I seem not to find any way to solve this. When the user wants to show the tag elements, then the tag database needs to be updated first. This happens over a linked server. Simplified:SP ShowTagsBEGININSERT INTO #WebSetFilters (Id, Name)EXEC dbo.webGetTags Select * from #WebSetFiltersENDSP WebGetTagsEXEC stpUpdateTagsselect * from tblTags...SP stpUpdateTags SET @selectString='SELECT tag FROM [classic] WHERE (pointsource = ' + '''FTLD''' + ' and pointtypex = ' + '''float32''' + ')' SET @selectString = N'select * from OPENQUERY(PI_HISTORIAN, ''' + REPLACE(@selectString, '''', '''''') + ''')' insert into #PI_HISTORIAN_PIPOINT EXEC (@selectString) insert into tblTags select * from #PI_HISTORIAN_PIPOINT
"INSERT EXEC cannot be done inside nested query"I seem not to find a way around this, except for putting all my code into a single stored procedure but that is not an option.I can not use 'openquery' because I have a variable querystring.I can not use functions because EXEC is not allowed in functions.Please help.