Solved

insert into #tab exec sp_help_job

Posted on 2004-04-14
3
1,960 Views
Last Modified: 2009-09-08
I,m running on sql-server 2000 in Query Analyzer.

I create the following table:
create table #tab (
job_id int,
originating_server nvarchar(30),
name sysname,
enabled tinyint,
description nvarchar(512),
start_step_id int,
category sysname,
owner sysname,
notify_level_eventlog int ,
notify_level_email int,
notify_level_netsend int,
notify_level_page int,
notify_email_operator  sysname,
notify_netsend_operator  sysname,
notify_page_operator  sysname,
delete_level int,
date_created datetime,
date_modified datetime,
version_number int,
last_run_date int,
last_run_time int,
last_run_outcome int,
next_run_date int,
next_run_time int,
next_run_schedule_id int,
current_execution_status  int,
current_execution_step sysname,
current_retry_attempt  int,
has_step int,
has_schedule int,
has_target int,
Type int)

Then I run the following query :
insert into #tab exec sp_help_job @description = 'Autogenerert'

Result :
Server: Msg 8164, Level 16, State 1, Procedure sp_get_composite_job_info, Line 67
An INSERT EXEC statement cannot be nested.

(0 row(s) affected)
------------------------------
I can see that the "exec sp_help_job @description = 'Autogenerert' " find one row, but why can I not populate the table #tab with the result from the procedure ?   Is it possible to do this in another way ?
0
Comment
Question by:olebrum030800
3 Comments
 
LVL 3

Accepted Solution

by:
edwardsearch earned 250 total points
ID: 10822183
It is possible by making sp_help_job as function
see the below example

create table #tab1 (name varchar(100), owner varchar(20), object_type varchar(20))

insert into #tab1 exec sp_help
exec sp_help
create function fntiedtest() returns @testtable table (name varchar(100), owner varchar(20), object_type varchar(20))
as
begin
INSERT @testtable select au_id as name, au_fname as owner, phone as object_type from pubs..authors
  RETURN
END
GO

insert into #tab1 select  * from dbo.tiedtest()


- Edward
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Error in WHERE Clause 5 42
Can someone plz fix this..getting an error 3 18
SQL Field Length for Email Address 3 17
MSSQL: Substring and Charindex error 7 19
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now