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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to insert selected columns

Author  Topic 

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2010-05-19 : 14:13:30
I am stucked while doing code ..I have below requirement and i got tired to use all approaches .Please suggest me on this


create table #jobactivity( job_id uniqueidentifier,
category varchar(50),
last_run_date int,
last_run_time int,
next_run_date int,
next_run_time int)

i am trying to populate this table using this command
insert into #jobactivity exec msdb..sp_help_job

but is is not working.Do i need to add same no of columns into the table? i want to take the selected columns into the table..Please help me on this.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-19 : 15:08:55
Yes you have to create the table with the same number of columns as the output of the stored procedure.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-20 : 09:03:53
Another method is using Openrowset
Refer point 2
http://beyondrelational.com/blogs/madhivanan/archive/2007/11/24/select-columns-from-exec-procedure-name-is-this-possible.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -