
Untitled
By: a guest on
May 27th, 2012 | syntax:
None | size: 2.23 KB | hits: 23 | expires: Never
-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE updateQuestions
-- Add the parameters for the stored procedure here
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
CREATE TABLE #Results
(
version INT,
field_length INT,
field_type_id INT,
html_form_type_id INT,
is_required tinyint,
name varchar(255),
precision INT,
question_type_id INT,
has_comments tinyint,
hasna tinyint,
sort_order INT
)
DECLARE @sqlQuery nvarchar(max);
SET @sqlQuery =
'Select version, field_length, field_type_id, html_form_type_id, is_required, name, precision,
CASE question_type_id
WHEN 1 THEN 28
WHEN 2 THEN 29
WHEN 3 THEN 30
WHEN 4 THEN 32
WHEN 5 THEN 33
WHEN 6 THEN 34
WHEN 7 THEN 35
WHEN 8 THEN 36
WHEN 13 THEN 37
END as question_type_id, has_comments, hasna, sort_order
FROM question
WHERE question_type_id in (1,2,3,4,5,6,7,8,13)'
PRINT @sqlQuery
INSERT #Results
EXEC(@sqlQuery);
--set identity_insert mbit.dbo.question on;
SET @sqlQuery = 'INSERT INTO [MBIT].[dbo].[question]
(
version, field_length, field_type_id, html_form_type_id, is_required, name, precision,
question_type_id, has_comments, hasna, sort_order
)
Select *
FROM #Results'
EXEC(@sqlQuery)
--set identity_insert mbit.dbo.question off;
SELECT * FROM #Results;
DROP TABLE #Results;
RETURN
END
GO