Escribiría un procedimiento para generar la tabla para mí:
CREATE PROCEDURE [dbo].[p_create_table_from_procedure]
@TABLE_NAME AS NVARCHAR(MAX),
@PROCEDURE_NAME AS NVARCHAR(MAX)
As
DECLARE @CREATE_TABLE_QUERY NVARCHAR(MAX) = N'';
SELECT
@CREATE_TABLE_QUERY += ', ' + name + ' ' + UPPER(system_type_name) + CHAR(13) + CHAR(10) + CHAR(9)
FROM
sys.dm_exec_describe_first_result_set(@procedure_name, NULL, 1);
SELECT
@CREATE_TABLE_QUERY = N'CREATE TABLE ' + @table_name + '(' + CHAR(13) + CHAR(10) + CHAR(9) + STUFF(@CREATE_TABLE_QUERY, 1, 1, N'') + ');';
PRINT @CREATE_TABLE_QUERY;
Luego llámalo con:
EXEC p_create_table_from_procedure 'YOUR_TABLE_NAME_HERE', 'YOUR_PROCEDURE_NAME_HERE'
Nota : Reemplace 'YOUR_PROCEDURE_NAME_HERE' con el nombre de su propio procedimiento almacenado.
Nota : Reemplace YOUR_TABLE_NAME_HERE con el nombre de la tabla que elija.
Lo anterior generará algo como esto:
CREATE TABLE YOUR_TABLE_NAME_HERE(
WeekName VARCHAR(40)
, Line Name VARCHAR(50)
, TheDate DATETIME
, ReceivedAll INT
, Answered INT
, Abandoned INT
, Call Length INT
, WaitTimeAnswer INT
, WaitTimeAbandon INT
, PeriodName VARCHAR(10)
, Week SMALLINT
, Period SMALLINT
, Year SMALLINT
, WeekInPeriod SMALLINT
, NumWeeksInPeriod SMALLINT
, WeekendDate DATETIME
, CRCOperative VARCHAR(100)
, CallType VARCHAR(20)
, Charge Time INT
, SourceNumber VARCHAR(80)
, DestinationNumber VARCHAR(80)
, CallStart DATETIME
, Out of Hours VARCHAR(12)
, IsWorkingDay BIT
);