As it stands my colleague will be running the below query 30 times.
EXEC dbo.usp.Nameofstoredprocedure '01-nov-2016'
It exports 3 rows with columns ID, Name, type
Is there anyway to have it export as:
Date, ID, name, type
01-nov-2016,10,john smith,man
01-nov-2016,11,jane smith,woman
02-nov-2016,10,john smith, man
02-nov-2016,11,jane smith,woman
etc.. The stored procedure in question is not something I can copy and paste in due to policy.
Thinking it over, I can see a loop might work, possibly inserting the row into a table but I can't figure out how to do this, any assistance would be great.
Work so far:
declare @date date
set @date = '2016-11-01'
declare @inte int
while @inte >= 30
select * into #temp EXEC dbo.usp_GetMaxUsers @date
set @date = DATEADD(dd,1,@date)
set @inte = @inte + 1
Right now it's giving me the following error:
Msg 263, Level 16, State 1, Line 4
Must specify table to select from.
Msg 1038, Level 15, State 5, Line 4
An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.
Thanks.