Reputation: 1
I have created the following SP and would like to output the data it returns to a new table on the same database. Been trying to use "SELECT * INTO table FROM" examples but with no luck.
What would be the best way to perform this function?
I have included the SP that I created for reference.
Thanks much!
USE [phoneview]
GO
/****** Object: StoredProcedure [dbo].[querySkillsOverall] Script Date: 10/4/2013 12:19:39 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Create date: 11/19/2012
-- Description: gets Skill info for Wallboard
-- =============================================
CREATE PROCEDURE [dbo].[querySkillsOverall]
-- Add the parameters for the stored procedure here
@ChannelName varchar(100),
@GroupName varchar(100)=NULL
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT
ROUND(CAST((SUM(tbl_SkillsLive.Abandoned)*100) as float)/NULLIF((SUM(tbl_SkillsLive.Received)),'0'),1) as 'Abandon %',
ROUND(((SUM(CAST(tbl_SkillsLive.WithinSLA as float))*100)/NULLIF(SUM(CAST(tbl_SkillsLive.Received as float)),'0')),1) as 'Within SLA %',
SUM(Received) as Received,
SUM(Abandoned) as Abandoned,
tbl_Channels.AbnExp,
tbl_Channels.AbnMin,
tbl_Channels.SLAExp,
tbl_Channels.SLAMin,
CASE WHEN SUM(tbl_SkillsLive.Handled) >=1 then (SUM(tbl_SkillsLive.ASA)/SUM(CASE WHEN ASA >0 THEN Handled ELSE NULL END)) Else NULL END as 'AnsTime'
FROM tbl_SkillsLive
LEFT JOIN tbl_Skills on tbl_Skills.Skill_KeyID = tbl_SkillsLive.Skill_KeyID
LEFT JOIN tbl_Skills_Channels_Link ON tbl_Skills_Channels_Link.Skill_KeyID = tbl_Skills.Skill_KeyID
LEFT JOIN tbl_Channels on tbl_Channels.ChannelID = tbl_Skills_Channels_Link.ChannelID
LEFT JOIN tbl_Groups on tbl_Groups.GroupID = tbl_Skills_Channels_Link.GroupID
WHERE tbl_Channels.Name = @ChannelName
AND (@GroupName is NULL OR tbl_Groups.Name = @GroupName)
GROUP BY tbl_Channels.Name,
tbl_Channels.AbnExp,
tbl_Channels.AbnMin,
tbl_Channels.SLAExp,
tbl_Channels.SLAMin
END
GO
Upvotes: 0
Views: 354
Reputation: 9
you need to use something like this to call the procedure:
INSERT INTO #temptable
SELECT * FROM dbo.querySkillsOverall(@ChannelName,@GroupName)
Upvotes: 0
Reputation:
The proc needs to return a table to the calling script in order for a select into
to work. Alternativly you could just have to proc insert into the table for you.
Upvotes: 0