CREATE TABLE [dbo].[examForDepart](
	[exam] [nvarchar](50) NOT NULL,
	[depart] [bigint] NOT NULL,
	[flow] [bit] NOT NULL,
 CONSTRAINT [PK_examForDepart] PRIMARY KEY CLUSTERED 
(
	[exam] ASC,
	[depart] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_examForDepart_exam]    Script Date: 10/29/2010 16:30:55 ******/
ALTER TABLE [dbo].[examForDepart]  WITH CHECK ADD  CONSTRAINT [FK_examForDepart_exam] FOREIGN KEY([exam])
REFERENCES [dbo].[exam] ([id])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[examForDepart] CHECK CONSTRAINT [FK_examForDepart_exam]
GO
/****** Object:  StoredProcedure [dbo].[we_score_reCalculate]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_reCalculate]
GO
/****** Object:  StoredProcedure [dbo].[we_score_reEnter]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_reEnter]
GO
/****** Object:  StoredProcedure [dbo].[we_score_resetEnterTimes]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_resetEnterTimes]
GO
/****** Object:  StoredProcedure [dbo].[we_score_startExam]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_startExam]
GO
/****** Object:  StoredProcedure [dbo].[we_score_submit]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_submit]
GO
/****** Object:  StoredProcedure [dbo].[we_score_submitCount]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_submitCount]
GO
/****** Object:  StoredProcedure [dbo].[we_score_updateStaticKey]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_updateStaticKey]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_examineesNewExamList]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_examineesNewExamList]
GO
/****** Object:  StoredProcedure [dbo].[we_score_addExaminee]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_addExaminee]
GO
/****** Object:  StoredProcedure [dbo].[we_score_addExamineeByPart]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_addExamineeByPart]
GO
/****** Object:  StoredProcedure [dbo].[we_score_addExamineeFromMyGroup]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_addExamineeFromMyGroup]
GO
/****** Object:  StoredProcedure [dbo].[we_score_AnalyseResult]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_AnalyseResult]
GO
/****** Object:  StoredProcedure [dbo].[we_score_averageScore]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_averageScore]
GO
/****** Object:  StoredProcedure [dbo].[we_score_calculateScore]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_calculateScore]
GO
/****** Object:  StoredProcedure [dbo].[we_score_count]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_count]
GO
/****** Object:  StoredProcedure [dbo].[we_score_delExaminee]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_delExaminee]
GO
/****** Object:  StoredProcedure [dbo].[we_score_getAScore]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_getAScore]
GO
/****** Object:  StoredProcedure [dbo].[we_score_getExamineesPage]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_getExamineesPage]
GO
/****** Object:  StoredProcedure [dbo].[we_score_getList]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_getList]
GO
/****** Object:  StoredProcedure [dbo].[we_score_getMyScoresPage]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_getMyScoresPage]
GO
/****** Object:  StoredProcedure [dbo].[we_score_getNotStaticKeyList]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_getNotStaticKeyList]
GO
/****** Object:  StoredProcedure [dbo].[we_score_inExamState]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_inExamState]
GO
/****** Object:  StoredProcedure [dbo].[we_score_ipToExamee]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_ipToExamee]
GO
/****** Object:  StoredProcedure [dbo].[we_score_myScoresCount]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_score_myScoresCount]
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_delete]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examForDepart_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_getByExam]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examForDepart_getByExam]
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_insert]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examForDepart_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_myExam]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examForDepart_myExam]
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_register]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examForDepart_register]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT0_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT0_AnalysePaper]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT0_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT0_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT0_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT0_in]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT1_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT1_AnalysePaper]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT1_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT1_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT1_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT1_in]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT10_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT10_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT10_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT10_in]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkDistribution]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_checkDistribution]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedCount]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_checkedCount]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedNext]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_checkedNext]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedPrev]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_checkedPrev]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedRange]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_checkedRange]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_count]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_count]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_groupNo]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_groupNo]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_in]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_up_score_checker]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_up_score_checker]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_upgroupNo]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT11_upgroupNo]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT2_AnalysePaper]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_checkDistribution]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT2_checkDistribution]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_checkedCountForTest]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT2_checkedCountForTest]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_checkedRange]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT2_checkedRange]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT2_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_getCount]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT2_getCount]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT2_in]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT3_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT3_AnalysePaper]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT3_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT3_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT3_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT3_in]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_AnalysePaper]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_checkDistribution]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_checkDistribution]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_checkedCountForTest]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_checkedCountForTest]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_checkedRange]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_checkedRange]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_getCount]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_getCount]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_in]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_up_score_checker]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT4_up_score_checker]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT5_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT5_AnalysePaper]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT5_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT5_get]
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT5_in]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_examineeKeyT5_in]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_delete]
GO
/****** Object:  StoredProcedure [dbo].[in_chengji_filter]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[in_chengji_filter]
GO
/****** Object:  StoredProcedure [dbo].[up_chengji_ipToAll]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_chengji_ipToAll]
GO
/****** Object:  StoredProcedure [dbo].[up_examineeKeyT2_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_examineeKeyT2_groupNo]
GO
/****** Object:  StoredProcedure [dbo].[up_examineeKeyT2_score_checker]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_examineeKeyT2_score_checker]
GO
/****** Object:  StoredProcedure [dbo].[up_examineeKeyT4_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_examineeKeyT4_groupNo]
GO
/****** Object:  StoredProcedure [dbo].[we_chcekerGroup_delByExamid]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_chcekerGroup_delByExamid]
GO
/****** Object:  StoredProcedure [dbo].[we_checkerGroup_getByExamId]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_checkerGroup_getByExamId]
GO
/****** Object:  StoredProcedure [dbo].[we_checkerGroup_getGroup]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_checkerGroup_getGroup]
GO
/****** Object:  StoredProcedure [dbo].[we_checkerGroup_in]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_checkerGroup_in]
GO
/****** Object:  StoredProcedure [dbo].[dl_user_DeleteUser]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_user_DeleteUser]
GO
/****** Object:  StoredProcedure [dbo].[examrenshu]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[examrenshu]
GO
/****** Object:  StoredProcedure [dbo].[fun_delExamineeKey]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_delExamineeKey]
GO
/****** Object:  StoredProcedure [dbo].[fun_delExamineesKey]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_delExamineesKey]
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t0]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_testScorePercent_t0]
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t1]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_testScorePercent_t1]
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t2]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_testScorePercent_t2]
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t3]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_testScorePercent_t3]
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t4]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_testScorePercent_t4]
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t5]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[fun_testScorePercent_t5]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT0_ek]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT0_ek]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT0_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT0_frequentKey]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT1_ek]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT1_ek]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT1_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT1_frequentKey]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_checkedCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT2_checkedCount]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_checkedNext]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT2_checkedNext]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_checkedPrev]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT2_checkedPrev]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT2_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT2_frequentKey]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT2_groupNo]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT3_ek]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT3_ek]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT3_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT3_frequentKey]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_checkedCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT4_checkedCount]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_checkedNext]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT4_checkedNext]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_checkedPrev]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT4_checkedPrev]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT4_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT4_groupNo]
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT5_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_examineeKeyT5_frequentKey]
GO
/****** Object:  StoredProcedure [dbo].[sl_group_groupNo_byExamId]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_group_groupNo_byExamId]
GO
/****** Object:  StoredProcedure [dbo].[sl_group_myTask]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_group_myTask]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_addRole]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_userRoles_addRole]
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_delByTargetId]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_userRoles_delByTargetId]
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_delRole]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_userRoles_delRole]
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getRoles]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_userRoles_getRoles]
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getUserByRole]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_userRoles_getUserByRole]
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getUserRangeByRole]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_userRoles_getUserRangeByRole]
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getUsersByRoleForDepart]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_userRoles_getUsersByRoleForDepart]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_getTestPageByDegreeKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_getTestPageByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_testsKeyWord_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_testsKeyWord_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_testsKeyWord_getByTest]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_testsKeyWord_getByTest]
GO
/****** Object:  StoredProcedure [dbo].[we_testsKeyWord_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_testsKeyWord_insert]
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_allFinish]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_exam_allFinish]
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_examid]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_exam_examid]
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_examid_end]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_exam_examid_end]
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_finish]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_exam_finish]
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_triggerTimer]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_exam_triggerTimer]
GO
/****** Object:  StoredProcedure [dbo].[sl_myGroup]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_myGroup]
GO
/****** Object:  StoredProcedure [dbo].[sl_myGroup_usersList]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_myGroup_usersList]
GO
/****** Object:  StoredProcedure [dbo].[sl_sms]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_sms]
GO
/****** Object:  StoredProcedure [dbo].[sl_sms_all]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_sms_all]
GO
/****** Object:  StoredProcedure [dbo].[sl_sms_byRead]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_sms_byRead]
GO
/****** Object:  StoredProcedure [dbo].[sl_sms_myall]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_sms_myall]
GO
/****** Object:  StoredProcedure [dbo].[dl_myGroup]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_myGroup]
GO
/****** Object:  StoredProcedure [dbo].[dl_myGroup_user]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_myGroup_user]
GO
/****** Object:  StoredProcedure [dbo].[dl_sms]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_sms]
GO
/****** Object:  StoredProcedure [dbo].[dl_sms_expired]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_sms_expired]
GO
/****** Object:  StoredProcedure [dbo].[in_skwusers_accordingGroup]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[in_skwusers_accordingGroup]
GO
/****** Object:  StoredProcedure [dbo].[in_sms]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[in_sms]
GO
/****** Object:  StoredProcedure [dbo].[up_myGroup_groupName]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_myGroup_groupName]
GO
/****** Object:  StoredProcedure [dbo].[up_exam_static]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_exam_static]
GO
/****** Object:  StoredProcedure [dbo].[up_exam_triggerTimer]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_exam_triggerTimer]
GO
/****** Object:  StoredProcedure [dbo].[in_myGroup]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[in_myGroup]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_getTestPageByDegreeKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_getTestPageByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_getTestPageByDegreeKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_getTestPageByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_countByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_countByKeyPointDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_countByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_countByKeyPointDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_countByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_countByKeyPointDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_countByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_countByKeyPointDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_getTestPageByDegreeKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_getTestPageByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_getTestPageByDegreeKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_getTestPageByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_getTestPageByDegreeKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_getTestPageByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_countByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_countByKeyPointDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_countByKeyPoint]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_countByKeyPointDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_add]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_add]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_changeCheckState]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_changeCheckState]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_delete]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_storeUsers_deleteByUserId]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_storeUsers_deleteByUserId]
GO
/****** Object:  StoredProcedure [dbo].[we_storeUsers_getBySubject]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_storeUsers_getBySubject]
GO
/****** Object:  StoredProcedure [dbo].[we_storeUsers_insert]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_storeUsers_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_changeSubjectId]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exampaper_changeSubjectId]
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_delete]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exampaper_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_getbyid]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exampaper_getbyid]
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_getmypaper]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exampaper_getmypaper]
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_getmypaperBySubject]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exampaper_getmypaperBySubject]
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_insert]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exampaper_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_renameTitle]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exampaper_renameTitle]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_examinerRuningExams]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_examinerRuningExams]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_get]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_get]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_getNew]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_getNew]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_myWaitExams]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_myWaitExams]
GO
/****** Object:  StoredProcedure [dbo].[we_exam_update]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_exam_update]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_countByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_getbyid]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_getByRan]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_getTestPage]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_getTestPageByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_t0_update]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t0_update]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_countByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_update]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_update]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_countByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_getbyid]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_getByRan]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_getTestPage]
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t1_getTestPageByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_update]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_update]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_countByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_getbyid]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_getByRan]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_getTestPage]
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t2_getTestPageByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_getbyid]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_getByRan]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_getTestPage]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_getTestPageByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_update]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_update]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_countByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_t3_update]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t3_update]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_countByDegree]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_getbyid]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_getByRan]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_getTestPage]
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t4_getTestPageByDegree]
GO
/****** Object:  StoredProcedure [dbo].[in_paperCenter]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[in_paperCenter]
GO
/****** Object:  StoredProcedure [dbo].[up_user_ChangePassword]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_ChangePassword]
GO
/****** Object:  StoredProcedure [dbo].[up_user_expiredDate]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_expiredDate]
GO
/****** Object:  StoredProcedure [dbo].[up_user_failedPasswordAnswerAttempt]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_failedPasswordAnswerAttempt]
GO
/****** Object:  StoredProcedure [dbo].[up_user_FailedPasswordAnswerAttemptCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_FailedPasswordAnswerAttemptCount]
GO
/****** Object:  StoredProcedure [dbo].[up_user_failedPasswordAttempt]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_failedPasswordAttempt]
GO
/****** Object:  StoredProcedure [dbo].[up_user_FailedPasswordAttemptCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_FailedPasswordAttemptCount]
GO
/****** Object:  StoredProcedure [dbo].[up_user_LastActivityDate]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_LastActivityDate]
GO
/****** Object:  StoredProcedure [dbo].[up_user_lastLoginDate]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_lastLoginDate]
GO
/****** Object:  StoredProcedure [dbo].[up_user_lockUser]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_lockUser]
GO
/****** Object:  StoredProcedure [dbo].[up_user_totalScore]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_user_totalScore]
GO
/****** Object:  StoredProcedure [dbo].[readtextkey]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[readtextkey]
GO
/****** Object:  StoredProcedure [dbo].[dl_t1]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_t1]
GO
/****** Object:  StoredProcedure [dbo].[dl_t2]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_t2]
GO
/****** Object:  StoredProcedure [dbo].[dl_t3]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_t3]
GO
/****** Object:  StoredProcedure [dbo].[dl_t4]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_t4]
GO
/****** Object:  StoredProcedure [dbo].[dl_t5]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_t5]
GO
/****** Object:  StoredProcedure [dbo].[dl_paperCenter]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_paperCenter]
GO
/****** Object:  StoredProcedure [dbo].[dl_user_GetNumberOfUsersOnline]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_user_GetNumberOfUsersOnline]
GO
/****** Object:  StoredProcedure [dbo].[sl_t0_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_t0_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_t1_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_t1_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_t2_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_t2_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_t3_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_t3_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_t4_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_t4_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_t5_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_t5_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_user_GetUserNameByEmail]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_user_GetUserNameByEmail]
GO
/****** Object:  StoredProcedure [dbo].[sl_user_totalScore]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_user_totalScore]
GO
/****** Object:  StoredProcedure [dbo].[sl_paperCenter]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_paperCenter]
GO
/****** Object:  StoredProcedure [dbo].[sl_PaperCenter_paperlist]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_PaperCenter_paperlist]
GO
/****** Object:  StoredProcedure [dbo].[we_user_ChangePasswordQuestionAndAnswer]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_ChangePasswordQuestionAndAnswer]
GO
/****** Object:  StoredProcedure [dbo].[we_user_CreateUser]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_CreateUser]
GO
/****** Object:  StoredProcedure [dbo].[we_user_GetUser]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_GetUser]
GO
/****** Object:  StoredProcedure [dbo].[we_user_getUsersPage]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_getUsersPage]
GO
/****** Object:  StoredProcedure [dbo].[we_user_getUsersTotalByDepart]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_getUsersTotalByDepart]
GO
/****** Object:  StoredProcedure [dbo].[we_user_logout]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_logout]
GO
/****** Object:  StoredProcedure [dbo].[we_user_upBaseInfo]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_upBaseInfo]
GO
/****** Object:  StoredProcedure [dbo].[we_user_updatePartId]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_updatePartId]
GO
/****** Object:  StoredProcedure [dbo].[we_user_upFoundPwdByEmailDate]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_user_upFoundPwdByEmailDate]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_update]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_update]
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_delete]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_TestKeyWord_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_getById]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_TestKeyWord_getById]
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_getBySubject]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_TestKeyWord_getBySubject]
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_insert]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_TestKeyWord_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_update]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_TestKeyWord_update]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_getbyid]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_getByRan]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_getTestPage]
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_t5_getTestPageByDegree]
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_schoolwork]
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork_ing]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_schoolwork_ing]
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork_unchecked]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_schoolwork_unchecked]
GO
/****** Object:  StoredProcedure [dbo].[we_data_add]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_add]
GO
/****** Object:  StoredProcedure [dbo].[we_data_delCataLog]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_delCataLog]
GO
/****** Object:  StoredProcedure [dbo].[we_data_delete]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getById]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getById]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getCheckedContentCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getCheckedContentCount]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getCheckedContentPage]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getCheckedContentPage]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getContentCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getContentCount]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getContentPage]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getContentPage]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getMyContentCount]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentCountByCatalogId]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getMyContentCountByCatalogId]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentPage]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getMyContentPage]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentPageByCatalogId]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getMyContentPageByCatalogId]
GO
/****** Object:  StoredProcedure [dbo].[we_data_getNew]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_getNew]
GO
/****** Object:  StoredProcedure [dbo].[we_data_updateShare]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_updateShare]
GO
/****** Object:  StoredProcedure [dbo].[we_data_updateStatus]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_updateStatus]
GO
/****** Object:  StoredProcedure [dbo].[we_data_updateTopic]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[we_data_updateTopic]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_deleteLeaf]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_deleteLeaf]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_getbyId]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_getbyId]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_getChildren]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_getChildren]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_insert]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_openRegByPage]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_openRegByPage]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_openRegCount]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_openRegCount]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_updateById]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_updateById]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_updateName]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_updateName]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_updateOrder]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_updateOrder]
GO
/****** Object:  StoredProcedure [dbo].[we_depart_verifyAliasName]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_depart_verifyAliasName]
GO
/****** Object:  StoredProcedure [dbo].[sl_data_MyNavigation]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_data_MyNavigation]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_deleteLeaf]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_subject_deleteLeaf]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_getbyId]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_subject_getbyId]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_getChildren]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_subject_getChildren]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_insert]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_subject_insert]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateById]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_subject_updateById]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateCMSSecure]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_subject_updateCMSSecure]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateName]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_subject_updateName]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateOrder]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_subject_updateOrder]
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateTestSecure]    Script Date: 11/04/2010 16:14:49 ******/
DROP PROCEDURE [dbo].[we_subject_updateTestSecure]
GO
/****** Object:  StoredProcedure [dbo].[we_log_add]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_log_add]
GO
/****** Object:  StoredProcedure [dbo].[we_log_delete]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_log_delete]
GO
/****** Object:  StoredProcedure [dbo].[we_log_getLimit]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_log_getLimit]
GO
/****** Object:  StoredProcedure [dbo].[we_log_nextPage]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_log_nextPage]
GO
/****** Object:  StoredProcedure [dbo].[we_log_prePage]    Script Date: 11/04/2010 16:14:48 ******/
DROP PROCEDURE [dbo].[we_log_prePage]
GO
/****** Object:  StoredProcedure [dbo].[sl_totalerror_byExamid]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_totalerror_byExamid]
GO
/****** Object:  StoredProcedure [dbo].[selectst0]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[selectst0]
GO
/****** Object:  StoredProcedure [dbo].[selectst1]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[selectst1]
GO
/****** Object:  StoredProcedure [dbo].[selectst2]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[selectst2]
GO
/****** Object:  StoredProcedure [dbo].[selectst3]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[selectst3]
GO
/****** Object:  StoredProcedure [dbo].[selectst5]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[selectst5]
GO
/****** Object:  StoredProcedure [dbo].[selectst8]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[selectst8]
GO
/****** Object:  StoredProcedure [dbo].[sl_HRstorage_query1]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_HRstorage_query1]
GO
/****** Object:  StoredProcedure [dbo].[up_shwUserid_checked]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_shwUserid_checked]
GO
/****** Object:  StoredProcedure [dbo].[up_shwUserid_score]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_shwUserid_score]
GO
/****** Object:  StoredProcedure [dbo].[up_shwUserid_score_date]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[up_shwUserid_score_date]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_allStuNavigation]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwUsers_allStuNavigation]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_byShwId_count]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwUsers_byShwId_count]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_byShwId_submitCount]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwUsers_byShwId_submitCount]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_byShwId_unsubmit]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwUsers_byShwId_unsubmit]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwusers_checked]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwusers_checked]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_handed]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwUsers_handed]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_mynewwork]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwUsers_mynewwork]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwusers_nochecked]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwusers_nochecked]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwusers_score]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwusers_score]
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_userWork]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_shwUsers_userWork]
GO
/****** Object:  StoredProcedure [dbo].[sl_t0_byidnum]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_t0_byidnum]
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork_checked]    Script Date: 11/04/2010 16:14:47 ******/
DROP PROCEDURE [dbo].[sl_schoolwork_checked]
GO
/****** Object:  StoredProcedure [dbo].[dl_schoolwork]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_schoolwork]
GO
/****** Object:  StoredProcedure [dbo].[dl_shwUsers]    Script Date: 11/04/2010 16:14:46 ******/
DROP PROCEDURE [dbo].[dl_shwUsers]
GO
/****** Object:  StoredProcedure [dbo].[dl_shwUsers]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_shwUsers    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_shwUsers]
	(
		@shwid nvarchar(50),
		@userId nvarchar(20)
	)
AS
	SET NOCOUNT ON
	DELETE FROM shwUsers
	WHERE (schoolworkid = @shwid) AND (userid = @userId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_schoolwork]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_schoolwork    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_schoolwork]
	(
		@id nvarchar(50),
		@author nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @userid nvarchar(200)
 SELECT @userid=author
	FROM schoolwork
	WHERE (id = @id)
	if not @userid is null 
	  if @userid=@author
	begin
	
	BEGIN TRANSACTION
	
	DELETE FROM schoolwork
	WHERE (id = @id) AND (author = @author)
	
	DELETE FROM shwUsers
	WHERE (schoolworkId = @id)
	COMMIT
	end
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork_checked]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_schoolwork_checked    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_schoolwork_checked]
	(
		@_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId nvarchar(50)='',
		@_RecordEndId nvarchar(50)='',
		@_IsNavigation bit= 0,
		@author nvarchar(20),
		@subjectId bigint=-1
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid nvarchar(50))
	if @subjectId=-1
      
           insert into @indextable(nid) SELECT id
	FROM schoolwork
	WHERE (author = @author) and (checked=1) order by id desc
    else
         insert into @indextable(nid) SELECT id
	FROM schoolwork
	WHERE (author = @author) and (checked=1)and(subjectId=@subjectId) order by id desc
    
    select @_RecordsCount=count(id) from @indextable
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     if @subjectId=-1
           select id,endtime from schoolwork where (author = @author) and (checked=1) and (id<=@_RecordStartId) and (id>@_RecordEndId)  order by id desc
      else
         select id,endtime from schoolwork where (author = @author) and (checked=1)and(subjectId=@subjectid) and (id<=@_RecordStartId) and (id>@_RecordEndId)  order by id desc
         
       
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_t0_byidnum]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_t0_byidnum    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[sl_t0_byidnum]
	(   @subjectid bigint,
		@id bigint,
		@number bigint
	)
AS
	/* SET NOCOUNT ON */
	declare @sqlstr varchar(900)
	set @sqlstr='SELECT top '+CAST(@number AS VARCHAR(8))+'  id,kemu, timu, a, b, c, d, e, f, da, mink, maxk,difficulty,plainText'
	set @sqlstr=@sqlstr+' FROM t0 where (id>='+CAST(@id AS VARCHAR(8))+') and (kemu='+CAST(@subjectid AS VARCHAR(8))+')'
	exec(@sqlstr)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_userWork]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwUsers_userWork    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwUsers_userWork]
	(
		@shwId nvarchar(50),
		@userId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT submitTime, score
	FROM shwUsers
	WHERE (schoolworkId = @shwid) AND (userId = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwusers_score]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwusers_score    Script Date: 2006-5-19 14:45:37 ******/
CREATE PROCEDURE [dbo].[sl_shwusers_score]

	(
		@shwId nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	SELECT userId, submitTime, score
	FROM shwUsers
	WHERE (schoolworkId = @shwId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwusers_nochecked]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwusers_nochecked    Script Date: 2006-5-19 14:45:37 ******/
CREATE PROCEDURE [dbo].[sl_shwusers_nochecked]
	(
		@shlId nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT userId
	FROM shwUsers
	WHERE (schoolworkId = @shlId) AND (checked = 0) AND (NOT (submitTime IS NULL))
	ORDER BY userId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_mynewwork]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwUsers_mynewwork    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwUsers_mynewwork]
	(
		@userid nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT shwUsers.schoolworkId, schoolwork.dateCreated, schoolwork.endTime
	FROM shwUsers INNER JOIN
	      schoolwork ON shwUsers.schoolworkId = schoolwork.id
	WHERE (shwUsers.userId = @userid) AND (shwUsers.submitTime IS NULL) AND 
	      (schoolwork.endTime > GETDATE())
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_handed]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwUsers_handed    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwUsers_handed]
	(
		@_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId nvarchar(50)='',
		@_RecordEndId nvarchar(50)='',
		@_IsNavigation bit= 0,
		@userid nvarchar(20),
		@subjectId bigint=-1
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid nvarchar(50))
	if @subjectId=-1
      
           insert into @indextable(nid) SELECT schoolworkId
                                        FROM shwUsers
                                        WHERE (userId = @userid) AND (NOT (submitTime IS NULL))
                                        ORDER BY schoolworkId DESC
    else
         insert into @indextable(nid) SELECT schoolwork.id
	FROM schoolwork INNER JOIN
      shwUsers ON schoolwork.id = shwUsers.schoolworkId
	WHERE (shwUsers.userid = @userid) and (not (shwUsers.submittime is null))and(schoolwork.subjectId=@subjectId) order by shwUsers.schoolworkId desc
    
    select @_RecordsCount=count(id) from @indextable
    -- SELECT id from @indextable
	 --FROM shwUsers
	 --WHERE (userid=@userid) and (not (shwUsers.submittime is null)) order by shwUsers.submittime desc
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     if @subjectId=-1
           select schoolworkId,shwUsers.submittime from shwUsers where (userid = @userid) and (not (shwUsers.submittime is null)) and (schoolworkId<=@_RecordStartId) and (schoolworkId>@_RecordEndId)  order by schoolworkId desc
      else
         select schoolworkid,shwUsers.submittime from schoolwork INNER JOIN
      shwUsers ON schoolwork.id = shwUsers.schoolworkId
      
       where (shwUsers.userid = @userid) and (not (shwUsers.submittime is null))and(schoolwork.subjectId=@subjectid) and (schoolworkid<=@_RecordStartId) and (schoolworkid>@_RecordEndId)  order by shwUsers.schoolworkId desc
         
       
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwusers_checked]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwusers_checked    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwusers_checked]
	(
		@shlId nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT userId
	FROM shwUsers
	WHERE (schoolworkId = @shlId) AND (checked = 1) order by userId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_byShwId_unsubmit]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwUsers_byShwId_unsubmit    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwUsers_byShwId_unsubmit]
	(
		@shwId nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT userId
	FROM shwUsers
	WHERE (schoolworkId = @shwId) AND (submitTime IS NULL)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_byShwId_submitCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwUsers_byShwId_submitCount    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwUsers_byShwId_submitCount]
	(
		@shwId nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(userId) AS Expr1
	FROM shwUsers
	WHERE (schoolworkId = @shwId) AND (NOT (submitTime IS NULL))
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_byShwId_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwUsers_byShwId_count    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwUsers_byShwId_count]
	(
		@shwId nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(userId) AS Expr1
	FROM shwUsers
	WHERE (schoolworkId = @shwId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_shwUsers_allStuNavigation]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_shwUsers_allStuNavigation    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_shwUsers_allStuNavigation]
	(
		@_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId nvarchar(20)='',
		@_RecordEndId nvarchar(20)='',
		@_IsNavigation bit= 0,
		
		@schoolworkid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid nvarchar(20))
	
      
           insert into @indextable(nid) select userid from shwUsers where schoolworkid = @schoolworkid order by userid desc
       
    
    select @_RecordsCount=count(id) from @indextable
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     
            select * from shwUsers where (userid<=@_RecordStartId) and (userid>@_RecordEndId) and (schoolworkid = @schoolworkid) order by userid desc
        
         
       
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_shwUserid_score_date]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_shwUserid_score_date    Script Date: 2006-5-19 14:45:40 ******/
CREATE PROCEDURE [dbo].[up_shwUserid_score_date]
	(
		@shwId nvarchar(50),
		@userId nvarchar(20),
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE shwUsers
	SET score = @score, submitTime =GETDATE ( )
	WHERE (schoolworkId = @shwId) AND (userId = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_shwUserid_score]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_shwUserid_score    Script Date: 2006-5-19 14:45:40 ******/
CREATE PROCEDURE [dbo].[up_shwUserid_score]
	(
		@shwId nvarchar(50),
		@userId nvarchar(20),
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE shwUsers
	SET score = @score
	WHERE (schoolworkId = @shwId) AND (userId = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_shwUserid_checked]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_shwUserid_checked    Script Date: 2006-5-19 14:45:40 ******/
CREATE PROCEDURE [dbo].[up_shwUserid_checked]
	(
		@shwId nvarchar(50),
		@userId nvarchar(20),
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE shwUsers
	SET score = @score,checked = 1
	WHERE (schoolworkId = @shwId) AND (userId = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_HRstorage_query1]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_HRstorage_query1    Script Date: 2006-5-19 14:45:30 ******/
CREATE PROCEDURE [dbo].[sl_HRstorage_query1]
	(
		@_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId nvarchar(20)='',
		@_RecordEndId nvarchar(20)='',
		@_IsNavigation bit= 0,
		
		@subjectId varchar(8)
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid int)
	
      
           insert into @indextable(nid) select serialnumber from hrStorage where certificateId=@subjectId order by serialnumber desc
       
    
    select @_RecordsCount=count(id) from @indextable
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     
            select hrStorage.userId,hrStorage.passDate, usersInfo.sex,usersInfo.username,usersInfo.birthday from hrStorage INNER JOIN
                  usersInfo ON hrStorage.userId = usersInfo.userId where (serialnumber<=@_RecordStartId) and (serialnumber>@_RecordEndId) AND (certificateId=@subjectId) order by serialnumber desc
        
         
       
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[selectst8]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.selectst8    Script Date: 2006-5-19 14:45:33 ******/
CREATE PROCEDURE [dbo].[selectst8]
	(@sjid bigint,
		@stid bigint
	)
AS
	 SET NOCOUNT ON 
	SELECT  tt8.timu,plainText
	FROM tt8
	WHERE (tt8.id = @stid) and (paperid=@sjid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[selectst5]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.selectst5    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[selectst5]
	(@sjid bigint,
		@stid bigint
	)
AS
	 SET NOCOUNT ON 
	SELECT  tt5.a, tt5.b, tt5.c, tt5.d, tt5.da,plainText
	FROM tt5
	WHERE (tt5.id = @stid) and (paperid=@sjid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[selectst3]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.selectst3    Script Date: 2006-5-19 14:45:33 ******/
CREATE PROCEDURE [dbo].[selectst3]
	(@sjid bigint,
		@stid bigint
	)
AS
	 SET NOCOUNT ON 
	SELECT tt3.timu, tt3.da,plainText
	FROM tt3
	WHERE (tt3.id = @stid) and (paperid=@sjid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[selectst2]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.selectst2    Script Date: 2006-5-19 14:45:33 ******/
CREATE PROCEDURE [dbo].[selectst2]
	(@sjid bigint,
		@stid bigint
	)
AS
	 SET NOCOUNT ON 
	SELECT tt2.timu, tt2.[rule],subjoinder,plainText
	FROM tt2
	WHERE (tt2.id = @stid) and (paperid=@sjid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[selectst1]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.selectst1    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[selectst1]
	(@sjid bigint,
		@stid bigint
	)
AS
	 SET NOCOUNT ON 
	SELECT tt1.timu, tt1.a, tt1.b, tt1.c, tt1.d, tt1.e, tt1.f, tt1.da,plainText
	FROM tt1 
	WHERE (tt1.id = @stid) and (paperid=@sjid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[selectst0]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.selectst0    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[selectst0]
	(@sjid bigint,
		@stid bigint
	)
AS
	 SET NOCOUNT ON 
	SELECT tt0.timu, tt0.a, tt0.b, tt0.c, tt0.d, tt0.e, tt0.f, tt0.da,plainText
	FROM tt0 
	WHERE (tt0.id = @stid) and (paperid=@sjid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_totalerror_byExamid]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_totalerror_byExamid    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[sl_totalerror_byExamid]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT examid, tx, stid, crs,tnxz
	FROM totalerror where examid=@examid
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_log_prePage]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_log_prePage]

	(
	@nextPageTop datetime
	)

AS
	/* SET NOCOUNT ON */
	select a.* from(
	SELECT TOP (20) logdate, logtype, msg
	FROM we_log
	WHERE (logdate > @nextPageTop)
	ORDER BY logdate 
	)a order by a.logdate desc
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_log_nextPage]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_log_nextPage]

	(
	@prePageBottom datetime
	)

AS
	/* SET NOCOUNT ON */
	SELECT TOP (20) logdate, logtype, msg
	FROM we_log
	WHERE (logdate < @prePageBottom)
	ORDER BY logdate DESC
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_log_getLimit]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_log_getLimit]

	(
	@min datetime output,
	@max datetime output
	)

AS
	/* SET NOCOUNT ON */
	SELECT @max=MAX(logdate)
	FROM we_log
	SELECT @min=Min(logdate)
	FROM we_log
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_log_delete]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_log_delete]
	
	(@comparedate datetime
	)
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM we_log
	WHERE (logdate < @comparedate)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_log_add]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_log_add]
	
	(
	@logdate datetime,
	@logtype smallint,
	@msg nvarchar(3000)
	)
	
AS
	/* SET NOCOUNT ON */
	INSERT INTO we_log
	      (logdate, logtype, msg)
	VALUES (@logdate,@logtype,@msg)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateTestSecure]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_updateTestSecure]
	
	(
	@subjectId bigint,
	@testSecure bit
	)
	
AS
	
	UPDATE kcxx
	SET testSecure =@testSecure
	WHERE (id = @subjectId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateOrder]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_updateOrder]
	
	(
	@subjectId bigint,
	@orderId int
	)
AS
	/* SET NOCOUNT ON */
	UPDATE kcxx
	SET orderId=@orderId
	WHERE (id = @subjectId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateName]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_updateName]
	
	(
	@subjectId bigint,
	@subjectName nvarchar(255)
	)
	
AS
	
	UPDATE kcxx
	SET subjectName =@subjectName
	WHERE (id = @subjectId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateCMSSecure]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_updateCMSSecure]
	(
	@subjectId bigint,
	@CMSSecure bit
	
	)
	
AS
	/* SET NOCOUNT ON */
	
	UPDATE kcxx
	SET CMSSecure =@CMSSecure
	WHERE (id = @subjectId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_updateById]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_updateById]
	
	(
	@subjectId bigint,
	@parentId bigint
	
	)
	
AS
	/* SET NOCOUNT ON */
	if @parentId<>0
    if not exists(	SELECT parentId
    	FROM kcxx
      	WHERE (id = @parentId))
    return
	UPDATE kcxx
	SET parentId =@parentId
	WHERE (id = @subjectId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_insert]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_insert]
	(
	
	@parentId bigint,
	@subjectName nvarchar(255),
	
	@learnSecure bit,
	@testSecure bit,
	@newId bigint output
	
	)
	
AS
	/* SET NOCOUNT ON */
	if @parentId<>0
    if not exists(	SELECT parentId
    	FROM kcxx
      	WHERE (id = @parentId))
    return
    declare @maxOrder int
    
    
    SELECT @maxOrder=max(orderId)
    	FROM kcxx
      	WHERE (parentId = @parentId)
      declare @newMax int	
      if @maxOrder is null	set @newMax=1 else set @newMax=@maxOrder+1
	INSERT INTO kcxx
	      (parentId, subjectName, learnSecure, testSecure,orderId)
	VALUES (@parentId,@subjectName,@learnSecure,@testSecure,@newMax)
	SET @newId=@@IDENTITY
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_getChildren]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_getChildren]
	
	(
	@parentId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT id, subjectName, learnSecure, testSecure,orderId,cmsSecure
	FROM kcxx
	WHERE (parentId = @parentId)
	ORDER BY orderId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_getbyId]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_getbyId]
	
	(
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT parentId, subjectName, learnSecure, testSecure,orderId,cmsSecure
	FROM kcxx
	WHERE (id = @subjectId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_subject_deleteLeaf]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_subject_deleteLeaf]
	(
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
if not exists	(SELECT id
	FROM kcxx
	WHERE (parentid = @subjectId))
	DELETE FROM kcxx
	WHERE (id = @subjectId) 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_data_MyNavigation]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_data_MyNavigation    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[sl_data_MyNavigation]
	(
		@_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId bigint=0,
		@_RecordEndId bigint=0,
		@_IsNavigation bit= 0,
		
		
		@adm nvarchar(20),
		@Attribute tinyint
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid bigint)
	
       
           insert into @indextable(nid) select id from data where (adm = @adm)and(Attribute=@Attribute) order by id desc
       
    
    select @_RecordsCount=count(id) from @indextable
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     
            select * from data where (adm = @adm)and(Attribute=@Attribute)and(id<=@_RecordStartId) and (id>@_RecordEndId) order by id desc
       
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_verifyAliasName]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_verifyAliasName]
	
	(@id bigint,
	@aliasName nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT count(Id)
	FROM dw
	WHERE (id<>@id)and(selfReg = 1)and(aliasName=@aliasName)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_updateOrder]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_updateOrder]
	
	(
	@departId bigint,
	@orderId int
	)
AS
	/* SET NOCOUNT ON */
	UPDATE dw
	SET orderId=@orderId
	WHERE (id = @departId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_updateName]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_updateName]
	
	(
	@departId bigint,
	@departName nvarchar(255)
	)
	
AS
	
	UPDATE dw
	SET departName =@departName
	WHERE (id = @departId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_updateById]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_updateById]
	
	(
	@departId bigint,
	@parentId bigint,
	@selfreg bit,
	@selfModifyProfile bit,
	@selfRegEx int,
	@aliasName nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	if @parentId<>0
    if not exists(	SELECT parentId
    	FROM dw
      	WHERE (id = @parentId))
    return
	UPDATE dw
	SET parentId =@parentId,selfReg =@selfreg, selfModifyProfile =@selfModifyProfile, selfRegEx =@selfRegEx,aliasName=@aliasName
	WHERE (id = @departId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_openRegCount]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[we_depart_openRegCount]
	
	
AS
	/* SET NOCOUNT ON */
	select count(id) from dw where (dw.selfReg=1)and(aliasName IS NOT null)
	
	

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_openRegByPage]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[we_depart_openRegByPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint
	)
	
AS
	/* SET NOCOUNT ON */
	
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) id,aliasName from dw where (dw.selfReg=1)and(aliasName IS NOT null) order by dw.id desc) a  order by a.id) b order by b.id desc
	

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_insert]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_insert]
	(
	
	@parentId bigint,
	@departName nvarchar(255),
	
	@selfreg bit,
	@selfModifyProfile bit,
	@newId bigint output
	
	)
	
AS
	/* SET NOCOUNT ON */
	if @parentId<>0
    if not exists(	SELECT parentId
    	FROM dw
      	WHERE (id = @parentId))
    return
    declare @maxOrder int
    
    
    SELECT @maxOrder=max(orderId)
    	FROM dw
      	WHERE (parentId = @parentId)
      declare @newMax int	
      if @maxOrder is null	set @newMax=1 else set @newMax=@maxOrder+1
	INSERT INTO dw
	      (parentId, departName, selfReg, selfModifyProfile,orderId)
	VALUES (@parentId,@departName,@selfreg,@selfModifyProfile,@newMax)
	SET @newId=@@IDENTITY
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_getChildren]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_getChildren]
	
	(
	@parentId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT id, departName, selfModifyProfile, selfReg,orderId,selfRegEx
	FROM dw
	WHERE (parentId = @parentId)
	ORDER BY orderId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_getbyId]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_getbyId]
	
	(
	@departId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT parentId, departName, selfModifyProfile, selfReg,orderId,selfRegEx,aliasName
	FROM dw
	WHERE (id = @departId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_depart_deleteLeaf]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_depart_deleteLeaf]
	(
		@departId bigint
	)
AS
	/* SET NOCOUNT ON */
if not exists	(SELECT id
	FROM dw
	WHERE (parentid = @departId))
	DELETE FROM dw
	WHERE (id = @departId) 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_updateTopic]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_updateTopic]
	(
		@id bigint,
		@topic nvarchar(450),
		@updateTime datetime
		
	)
AS
	
	UPDATE  data
	SET         topic = @topic, status = 0, updateTime = @updateTime
	WHERE   (id = @id) 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_updateStatus]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_updateStatus]
	(
		@id bigint,
		@status tinyint
		
	)
AS
	
	UPDATE data
	SET status = @status
	WHERE (id = @id) 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_updateShare]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_updateShare]
	(
		@id bigint,
		@share bit
		
	)
AS
	
	UPDATE data
	SET share = @share
	WHERE (id = @id) 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getNew]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getNew]
	
	(
	@attr int,
	@count int
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT TOP (@count) *
	FROM data
	WHERE (attribute = @attr)
	ORDER BY updateTime DESC 
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentPageByCatalogId]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getMyContentPageByCatalogId]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	@catalogId bigint,

	@attr int,
	@adm nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from data where (catalogId=@catalogId)and(data.attribute=@attr)and(data.adm=@adm) order by data.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentPage]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getMyContentPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	

	@attr int,
	@adm nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from data where (data.attribute=@attr)and(data.adm=@adm) order by data.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentCountByCatalogId]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getMyContentCountByCatalogId]
	
	(@catalogId bigint,
	@adm nvarchar(20),

	@attr int,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM data 
	WHERE (catalogId=@catalogId)and(attribute=@attr)and(adm=@adm)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getMyContentCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getMyContentCount]
	
	(
	@adm nvarchar(20),

	@attr int,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM data 
	WHERE (attribute=@attr)and(adm=@adm)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getContentPage]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getContentPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@catalogId bigint,
	@attr int
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from data where (data.catalogId=@catalogId)and(data.attribute=@attr) order by data.status,data.id desc) a  order by a.status desc, a.id) b order by b.status, b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getContentCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getContentCount]
	
	(
	@catalogId bigint,
	@attr int,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM data 
	WHERE (catalogId=@catalogId)and(attribute=@attr)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getCheckedContentPage]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getCheckedContentPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@catalogId bigint,
	@attr int
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from data where (data.catalogId=@catalogId)and(data.attribute=@attr)and(status=2) order by data.status,data.id desc) a  order by a.status desc, a.id) b order by b.status, b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getCheckedContentCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getCheckedContentCount]
	
	(
	@catalogId bigint,
	@attr int,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM data 
	WHERE (catalogId=@catalogId)and(attribute=@attr)and(status=2)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_getById]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_getById]
	(   
		@id bigint
	)
AS
	/* SET NOCOUNT ON */
	SELECT id, topic, adm, updateTime, catalogId, summary, status, path, attribute,defaultFile
	FROM data
	WHERE (id = @id)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_delete]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_delete](
		@id bigint
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM data
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_delCataLog]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_delCataLog]
	
	(
	@catalogId bigint,
	@attr int
	)
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM data
	WHERE (catalogId = @catalogId) AND (attribute = @attr)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_data_add]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_data_add]
	(
		@topic nvarchar(450),
		@adm nvarchar(20),
		
		@subjectId bigint,
		@attribute int,
		@summary nvarchar(450),
		@share bit,
		@path nvarchar(450),
		@updateTime datetime,
		@defaultFile nvarchar(450),
		@status tinyint
	)
AS
	/* SET NOCOUNT ON
	if exists(select id from data where path=@path)
	delete data where path=@path */
	INSERT INTO data
	      (topic, adm, catalogId, attribute, share, path, updateTime, summary,defaultFile,status)
	VALUES (@topic,@adm,@subjectId,@attribute,@share,@path,@updateTime,@summary,@defaultFile,@status)
	SELECT @@IDENTITY
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork_unchecked]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_schoolwork_unchecked    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_schoolwork_unchecked]
	(
		@author nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT schoolwork.id as id, schoolwork.dateCreated as dateCreated, kcxx.dwmc as subjectName
	FROM schoolwork INNER JOIN
	      kcxx ON schoolwork.subjectId = kcxx.id
	WHERE (schoolwork.author = @author) AND (schoolwork.checked = 0) AND 
	      (schoolwork.endTime < GETDATE())
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork_ing]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_schoolwork_ing    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_schoolwork_ing]
	(
		@_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId nvarchar(50)='',
		@_RecordEndId nvarchar(50)='',
		@_IsNavigation bit= 0,
		@author nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid nvarchar(50))
	
      
           insert into @indextable(nid) SELECT id
	FROM schoolwork
	WHERE (author = @author) and (endtime>getdate()) order by endtime desc
       
    
    select @_RecordsCount=count(id) from @indextable
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     
           SELECT schoolwork.id, schoolwork.dateCreated, schoolwork.endTime, kcxx.dwmc
           FROM schoolwork INNER JOIN
                 kcxx ON schoolwork.subjectId = kcxx.id
           WHERE (schoolwork.author = @author) AND (schoolwork.endTime > GETDATE()) AND 
                 (schoolwork.id <= @_RecordStartId) AND (schoolwork.id > @_RecordEndId)
           ORDER BY schoolwork.endTime DESC
         
         
       
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_schoolwork]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_schoolwork    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_schoolwork]
	(
		@id nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	
	SELECT schoolwork.author, schoolwork.endTime, schoolwork.dateCreated, 
	      kcxx.dwmc,schoolwork.subjectid
	FROM schoolwork INNER JOIN
	      kcxx ON schoolwork.subjectId = kcxx.id
	WHERE (schoolwork.id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_getTestPageByDegree]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t5 where (t5.subjectId=@subjectId)and(degree=@degree) order by t5.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_getTestPage]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t5 where (t5.subjectId=@subjectId) order by t5.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_getByRan]
	(   
		@subjectId bigint,
		@degree int,
		@total int,
		@kp bigint 
	)
AS
	/* SET NOCOUNT ON */
	if (@kp=-1)
	begin
	   if(@degree=-1)
	     SELECT  top (@total) * FROM t5 WHERE (subjectId=@subjectId) order by newid()
	   else
	     SELECT  top (@total) * FROM t5 WHERE (subjectId=@subjectId)and(degree=@degree) order by newid()
	end
	else
	begin
	   if(@degree=-1)
	     SELECT  top (@total) t5.* FROM t5
	      INNER JOIN
      WE_TestKeyWord ON t5.subjectId = WE_TestKeyWord.subjectId
WHERE (t5.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp) order by newid()
	   else
	     SELECT  top (@total) t5.* FROM t5 
	      INNER JOIN
      WE_TestKeyWord ON t5.subjectId = WE_TestKeyWord.subjectId
WHERE (t5.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp)and(degree=@degree) order by newid()
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_getbyid]
	(   
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	SELECT  *
	FROM t5
	WHERE (subjectId=@subjectId)and(id = @id) 
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_update]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_TestKeyWord_update]
	
	(
	@id bigint,
	@subjectId bigint,
	@name nvarchar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	
	UPDATE WE_TestKeyWord
	SET keyWord = @name
	WHERE (id = @id)and(subjectid=@subjectId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_TestKeyWord_insert]
	
	(
	@subjectId bigint,
	@keyWord nvarchar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	
	if not exists(select id from WE_TestKeyWord where (subjectId=@subjectId)and(keyWord=@keyWord))
	begin
	INSERT INTO WE_TestKeyWord
	      (subjectId, keyWord)
	VALUES (@subjectId,@keyWord)
	
	select @@IDENTITY
	end
	else
	select id from WE_TestKeyWord where (subjectId=@subjectId)and(keyWord=@keyWord)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_getBySubject]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_TestKeyWord_getBySubject]
	
	(
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT id,  keyWord
	FROM WE_TestKeyWord
	WHERE (subjectId = @subjectId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_getById]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_TestKeyWord_getById]
	
	(
	@id bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT keyWord
	FROM WE_TestKeyWord
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_TestKeyWord_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_TestKeyWord_delete]
	
	(
	@id bigint,
	@subjectId bigint
	
	)
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM WE_TestKeyWord
	WHERE (id = @id)and(subjectid=@subjectId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_update]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_update]
	(   @subjectId bigint,
	    @id bigint,
	    @plainText bit,
		
		@a nvarchar(450),
		@b nvarchar(450),
		@c nvarchar(450),
		@d nvarchar(450),
		
		@degree tinyint,
		@sa decimal(3,2),
		@sb decimal(3,2),
		@sc decimal(3,2),
		@sd decimal(3,2),
		@comment nvarchar(100)
		
	)
AS
	/* SET NOCOUNT ON */
	UPDATE t5
	SET a = @a, b = @b, c = @c, d = @d,  plainText=@plainText,degree=@degree,SA=@sa,SB=@sb,SC=@sc,SD=@sd,
		comment=@comment
	WHERE (subjectid=@subjectId)and(id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_insert]
	(@subjectId bigint,
		@plainText bit,
	
		@a nvarchar(450),
		@b nvarchar(450),
		@c nvarchar(450),
		@d nvarchar(450),
		
		@degree tinyint,
		@sa decimal(3,2),
		@sb decimal(3,2),
		@sc decimal(3,2),
		@sd decimal(3,2),
		@comment nvarchar(100)
		
		
		
		
	)
AS
	/* SET NOCOUNT ON */
	declare @testId bigint
	SELECT @testId=id
	              FROM t5
	              WHERE (a = @a)and(b = @b)and(c = @c)and(d = @d)and(subjectId=@subjectId)
	if @testId is null
	begin
	INSERT INTO t5
	      (subjectId, a, b, c, d,SA,SB,SC,SD, plainText, degree,comment)
	VALUES (@subjectId,@a,@b,@c,@d,@sa,@sb,@sc,@sd,@plainText,@degree,@comment)
	 
	select @@IDENTITY--题目id SELECT @stid=@@IDENTITY--题目id
	end
	else
	select @testId
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_upFoundPwdByEmailDate]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_upFoundPwdByEmailDate]
	
	(
	@userId nvarchar(20),
	@foundDate datetime,
	@validateCodeForFundePwd varchar(20)

	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [user]
	SET findPwdByEmailDate = @foundDate, 
	      validateCodeForFundePwd = @validateCodeForFundePwd
	WHERE (id = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_updatePartId]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_updatePartId]
	
	(
	@userId nvarchar(20),
	@newPartId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [user]
	SET departId=@newPartId
	WHERE (id = @userId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_upBaseInfo]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_upBaseInfo]
	
	(
	@userId nvarchar(20),
	@birthday datetime,
	@isMan bit,
	@userName nvarchar(50),
	@email nvarchar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [user]
	SET birthday = @birthday, isMan = @isMan, userName = @userName, 
	      Email = @email
	WHERE (id = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_logout]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_logout]
	
	(
	@userId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [User]  SET ip=null  WHERE Id =@userId 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_getUsersTotalByDepart]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_getUsersTotalByDepart]
	
	(
	@departId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT count(id)
	FROM [user] where departId=@departId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_getUsersPage]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_getUsersPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@departId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from [user] where ([user].departId=@departId) order by [user].id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_GetUser]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_GetUser]
	
	(
	@userId nvarchar(20)
	
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT Email, PasswordQuestion, IsLockedOut, CreationDate, LastLoginDate, 
	      LastActivityDate, LastPasswordChangedDate, LastLockedOutDate, password, 
	      PasswordAnswer, FailedPasswordAttemptCount, FailedPasswordAttemptWindowStart, 
	      FailedPasswordAnswerAttemptCount, FailedPasswordAnswerAttemptWindowStart, 
	      expiredDate, departId, userName, isMan, birthday, ip, findPwdByEmailDate,validateCodeForFundePwd
	FROM [user]
	WHERE (id = @userId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_CreateUser]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_CreateUser]
	(@userId nvarchar(20),
	 @password nvarchar(50),
	 @LastPasswordChangedDate datetime,
	 @PasswordQuestion nvarchar(50),
	 @PasswordAnswer nvarchar(50),
	 @Email nvarchar(50),

	 @CreationDate datetime,
	 @LastActivityDate datetime,
	 @IsLockedOut bit,
	 @LastLockedOutDate datetime,
	 @FailedPasswordAttemptCount int,
	 @FailedPasswordAttemptWindowStart datetime,
	 @FailedPasswordAnswerAttemptCount int,
	 @FailedPasswordAnswerAttemptWindowStart datetime,
	 @departmentId bigint,
	 @userName nvarchar(50),
	 @birthday datetime,
	 @isMan bit,
	 @expiredDate datetime
	)
AS
	/* SET NOCOUNT ON */
	INSERT INTO [user]
	      (departId, id, password, LastPasswordChangedDate, PasswordQuestion, 
	      PasswordAnswer, Email, CreationDate, LastActivityDate, IsLockedOut, 
	      LastLockedOutDate, FailedPasswordAttemptCount, 
	      FailedPasswordAttemptWindowStart, FailedPasswordAnswerAttemptCount, 
	      FailedPasswordAnswerAttemptWindowStart, userName, birthday, isMan,expiredDate)
	VALUES (@departmentId,@userId,@password,@LastPasswordChangedDate,@PasswordQuestion,@PasswordAnswer,@Email,@CreationDate,@LastActivityDate,@IsLockedOut,@LastLockedOutDate,@FailedPasswordAttemptCount,@FailedPasswordAttemptWindowStart,@FailedPasswordAnswerAttemptCount,@FailedPasswordAnswerAttemptWindowStart,@userName,@birthday,@isMan,@expiredDate)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_user_ChangePasswordQuestionAndAnswer]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_user_ChangePasswordQuestionAndAnswer]
	
	(
	@userId nvarchar(20),
	@Question nvarchar(50),
	@Answer nvarchar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [user] set PasswordQuestion=@Question, PasswordAnswer=@Answer
	
	WHERE (id = @userId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_PaperCenter_paperlist]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_PaperCenter_paperlist    Script Date: 2006-5-19 14:45:34 ******/
CREATE PROCEDURE [dbo].[sl_PaperCenter_paperlist]
(
    @_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId nvarchar(50)='',
		@_RecordEndId nvarchar(50)='',
		@_IsNavigation bit= 0
		)
AS

if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid bigint)
	
      
           insert into @indextable(nid)SELECT PaperCenter.id
FROM PaperCenter

ORDER BY id DESC
       
    
    select @_RecordsCount=count(id) from @indextable
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     
           select subjecid,PaperCenter.title, PaperCenter.updatetime, PaperCenter.id,PaperCenter.scriptid from PaperCenter where  (id<=@_RecordStartId) and (id>@_RecordEndId)  order by id desc
         
	end
GO
/****** Object:  StoredProcedure [dbo].[sl_paperCenter]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_paperCenter    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_paperCenter]

	(
		@subjectId bigint
	)

AS
	/* SET NOCOUNT ON */
	SELECT id, subjecId, title,updateTime
	FROM paperCenter
	WHERE (subjecId = @subjectId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_user_totalScore]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_user_totalScore    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[sl_user_totalScore]
	(
		@uid nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT totalScore
	FROM [user]
	WHERE (id = @uid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_user_GetUserNameByEmail]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sl_user_GetUserNameByEmail]
	
	(
	@email nvarchar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT id FROM [User]  WHERE Email = @email
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_t5_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_t5_count    Script Date: 2006-5-19 14:45:39 ******/
CREATE PROCEDURE [dbo].[sl_t5_count]
	
	(
	@subjectId bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t5 where subjectId=@subjectId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_t4_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_t4_count    Script Date: 2006-5-19 14:45:39 ******/
CREATE PROCEDURE [dbo].[sl_t4_count]
	
	(
	@subjectId bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t4 where subjectId=@subjectId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_t3_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_t3_count    Script Date: 2006-5-19 14:45:38 ******/
CREATE PROCEDURE [dbo].[sl_t3_count]
	
	(
	@subjectId bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t3 where subjectId=@subjectId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_t2_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_t2_count    Script Date: 2006-5-19 14:45:38 ******/
CREATE PROCEDURE [dbo].[sl_t2_count]
	
	(
	@subjectId bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t2 where subjectId=@subjectId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_t1_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_t1_count    Script Date: 2006-5-19 14:45:38 ******/
CREATE PROCEDURE [dbo].[sl_t1_count]
	
	(
	@subjectId bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t1 where subjectId=@subjectId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_t0_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_t0_count    Script Date: 2006-5-19 14:45:37 ******/
CREATE PROCEDURE [dbo].[sl_t0_count]
	
	(
	@subjectId bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t0 where subjectId=@subjectId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_user_GetNumberOfUsersOnline]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dl_user_GetNumberOfUsersOnline]
	
	(
	@CompareDate datetime
	
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT Count(*)
	FROM [user] where LastActivityDate>@CompareDate
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_paperCenter]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_paperCenter    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_paperCenter]

	(
		@id bigint,
		@subjectId bigint
	)

AS
	/* SET NOCOUNT ON */
	DELETE FROM paperCenter
	WHERE (id = @id)and(subjecid=@subjectid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_t5]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_t5    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_t5]
	(
		@id bigint
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM t5
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_t4]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_t4    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_t4]
	(
		@id bigint
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM t4
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_t3]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_t3    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_t3]
	(
		@id bigint
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM t3
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_t2]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_t2    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_t2]
	(
		@id bigint
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM t2
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_t1]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_t1    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_t1]
	(
		@id bigint
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM t1
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[readtextkey]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.readtextkey    Script Date: 2006-5-19 14:45:33 ******/
CREATE PROCEDURE [dbo].[readtextkey]
	(
		@stid bigint
	)
AS
	 SET NOCOUNT ON 
	SELECT plainText,[text], [key]
	FROM t8
	WHERE (id = @stid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_totalScore]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_user_totalScore    Script Date: 2006-5-19 14:45:29 ******/
CREATE PROCEDURE [dbo].[up_user_totalScore]
	(
		@uId nvarchar(20),
		@point int
	)
AS
	/* SET NOCOUNT ON */
	UPDATE [user]
	SET totalScore =totalScore+ @point where id = @uId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_lockUser]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_lockUser]
	
	(
	@userId nvarchar(20),
	@locked bit,
	@lastLockedOutDate datetime
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [user]
	SET IsLockedOut =@locked, LastLockedOutDate =@lastLockedOutDate
	WHERE (id = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_lastLoginDate]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_lastLoginDate]
	
	(
	@userId nvarchar(20),
	@lastLoginDate datetime,
	@loginIp varchar(30)
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [User]  SET LastLoginDate = @lastLoginDate, LastActivityDate = @lastLoginDate,ip=@loginIp  WHERE Id =@userId 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_LastActivityDate]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_LastActivityDate]
	
	(
	@lastActivityDate datetime,
	@userId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [User] SET LastActivityDate = @lastActivityDate WHERE id = @userId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_FailedPasswordAttemptCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_FailedPasswordAttemptCount]
	
	(
	@userId nvarchar(20),
	@FailedPasswordAttemptCount int
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [User] SET FailedPasswordAttemptCount =@FailedPasswordAttemptCount WHERE id = @userId
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_failedPasswordAttempt]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_failedPasswordAttempt]
	
	(
	@userId nvarchar(20),
	@failedPasswordAttemptCount int,
	@failedPasswordAttemptWindowStart datetime
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [User] SET FailedPasswordAttemptCount = @failedPasswordAttemptCount, FailedPasswordAttemptWindowStart =@failedPasswordAttemptWindowStart WHERE id =@userId 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_FailedPasswordAnswerAttemptCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_FailedPasswordAnswerAttemptCount]
	
	(
	@userId nvarchar(20),
	@FailedPasswordAnswerAttemptCount int
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [User] SET FailedPasswordAnswerAttemptCount =@FailedPasswordAnswerAttemptCount WHERE id = @userId
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_failedPasswordAnswerAttempt]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_failedPasswordAnswerAttempt]
	
	(
	@userId nvarchar(20),
	@failedPasswordAnswerAttemptCount int,
	@failedPasswordAnswerAttemptWindowStart datetime
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [User] SET FailedPasswordAnswerAttemptCount = @failedPasswordAnswerAttemptCount, FailedPasswordAnswerAttemptWindowStart =@failedPasswordAnswerAttemptWindowStart WHERE id =@userId 
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_expiredDate]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_user_expiredDate    Script Date: 2006-5-19 14:45:29 ******/
CREATE PROCEDURE [dbo].[up_user_expiredDate]
	(
		@userid nvarchar(20),
		
		@expiredDate datetime
		
	)
AS
	/* SET NOCOUNT ON */
	UPDATE [user]
	SET  expiredDate=@expiredDate where id = @userid
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_user_ChangePassword]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[up_user_ChangePassword]
	
	(
	@userId nvarchar(20),
	@password varchar(50),
	@LastPasswordChangedDate datetime
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE [user]
	SET password = @password, LastPasswordChangedDate = @LastPasswordChangedDate, 
	      findPwdByEmailDate = NULL, validateCodeForFundePwd = NULL
	WHERE (id = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[in_paperCenter]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.in_paperCenter    Script Date: 2006-5-19 14:45:32 ******/
CREATE PROCEDURE [dbo].[in_paperCenter]

	(
		@subjectId bigint,
		@title nvarchar(450),
		@scriptId bigint
	)

AS
	/* SET NOCOUNT ON */
	if not exists (select id from papercenter where (subjecId=@subjectId) and (scriptId=@scriptId))
	INSERT INTO paperCenter
	      (subjecId, title,scriptId,updatetime)
	VALUES (@subjectId, @title,@scriptId,getdate())
	else
	UPDATE paperCenter
	SET  title = @title, updatetime=getdate() where (subjecId = @subjectId) and (scriptId = @scriptId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_getTestPageByDegree]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t4 where (t4.subjectId=@subjectId)and(degree=@degree) order by t4.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_getTestPage]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t4 where (t4.subjectId=@subjectId) order by t4.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_getByRan]
	(   
		@subjectId bigint,
		@degree int,
		@total int,
		@kp bigint 
	)
AS
	/* SET NOCOUNT ON */
	if (@kp=-1)
	begin
	   if(@degree=-1)
	     SELECT  top (@total) * FROM t4 WHERE (subjectId=@subjectId) order by newid()
	   else
	     SELECT  top (@total) * FROM t4 WHERE (subjectId=@subjectId)and(degree=@degree) order by newid()
	end
	else
	begin
	   if(@degree=-1)
	     SELECT  top (@total) t4.* FROM t4
	      INNER JOIN
      WE_TestKeyWord ON t4.subjectId = WE_TestKeyWord.subjectId
WHERE (t4.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp) order by newid()
	   else
	     SELECT  top (@total) t4.* FROM t4 
	      INNER JOIN
      WE_TestKeyWord ON t4.subjectId = WE_TestKeyWord.subjectId
WHERE (t4.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp)and(degree=@degree) order by newid()
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_getbyid]
	(   @id bigint,
		@subjectid bigint
	)
AS
	/* SET NOCOUNT ON */
	SELECT timu, testKey,  degree, plainText, subjoinder, subjectId, updateTime, degree, comment
	FROM t4
	WHERE (subjectId=@subjectId)and(id = @id) 
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_countByDegree]
	(
	@subjectId bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t4 where (subjectId=@subjectId)and(degree=@degree)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_update]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_update]
	(   @subjectId bigint,
	    @id bigint,
	    @plainText bit,
		@timu nvarchar(450),
		@subjoinder nvarchar(2000),
		@degree tinyint,
		@SY decimal(3,2),
		@SN decimal(3,2),
		@comment nvarchar(100)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE t3
	SET timu = @timu, SY = @SY,SN=@SN, plainText=@plainText,degree=@degree,subjoinder=@subjoinder,
		comment=@comment
	WHERE (subjectid=@subjectId)and(id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_insert]
	(@subjectId bigint,
		@plainText bit,
		@timu nvarchar(450),
		@subjoinder nvarchar(2000),
		@degree tinyint,
		@SY decimal(3,2),
		@SN decimal(3,2),
		@comment nvarchar(100)
		
		
		
	)
AS
	/* SET NOCOUNT ON */
	declare @testId bigint
	SELECT @testId=id
	              FROM t3
	              WHERE (timu = @timu)and(subjectId=@subjectId)
	if @testId is null
	begin
	INSERT INTO t3
	      (timu, subjectId, SY,SN, plainText, degree,subjoinder, comment)
	VALUES (@timu,@subjectId,@SY,@SN,@plainText,@degree,@subjoinder,@comment)
	 
	select @@IDENTITY--题目id SELECT @stid=@@IDENTITY--题目id
	end
	else
	select @testId
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_countByDegree]
	(
	@subjectId bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t5 where (subjectId=@subjectId)and(degree=@degree)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_update]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_update]
	(   @subjectId bigint,
	    @id bigint,
	    @plainText bit,
		@timu nvarchar(450),
		@subjoinder nvarchar(2000),
		@degree tinyint,
		@key nvarchar(max),
		@comment nvarchar(100)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE  t4
	SET         timu = @timu, testKey = @key, plainText = @plainText, degree = @degree, subjoinder = @subjoinder, 
	                comment = @comment
	WHERE   (subjectId = @subjectId) AND (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_insert]
	(@subjectId bigint,
		@plainText bit,
		@timu nvarchar(450),
		@subjoinder nvarchar(2000),
		@degree tinyint,
		@key nvarchar(max),
		@comment nvarchar(100)
		
		
		
	)
AS
	/* SET NOCOUNT ON */
	declare @testId bigint
	SELECT @testId=id
	              FROM t4
	              WHERE (timu = @timu)and(subjectId=@subjectId)
	if @testId is null
	begin
	INSERT INTO t4
	      (timu, subjectId, testKey, plainText, degree,subjoinder,comment)
	VALUES (@timu,@subjectId,@key,@plainText,@degree,@subjoinder,@comment)
	 
	select @@IDENTITY--题目id SELECT @stid=@@IDENTITY--题目id
	end
	else
	select @testId
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_getTestPageByDegree]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t3 where (t3.subjectId=@subjectId)and(degree=@degree) order by t3.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_getTestPage]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t3 where (t3.subjectId=@subjectId) order by t3.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_getByRan]
	(   
		@subjectId bigint,
		@degree int,
		@total int,
		@kp bigint 
	)
AS
	/* SET NOCOUNT ON */
	if (@kp=-1)
	begin
	   if(@degree=-1)
	     SELECT  top (@total) * FROM t3 WHERE (subjectId=@subjectId) order by newid()
	   else
	     SELECT  top (@total) * FROM t3 WHERE (subjectId=@subjectId)and(degree=@degree) order by newid()
	end
	else
	begin
	   if(@degree=-1)
	     SELECT  top (@total) t3.* FROM t3
	      INNER JOIN
      WE_TestKeyWord ON t3.subjectId = WE_TestKeyWord.subjectId
WHERE (t3.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp) order by newid()
	   else
	     SELECT  top (@total) t3.* FROM t3 
	      INNER JOIN
      WE_TestKeyWord ON t3.subjectId = WE_TestKeyWord.subjectId
WHERE (t3.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp)and(degree=@degree) order by newid()
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_getbyid]
	(   
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	SELECT *
	FROM t3
	WHERE (subjectId=@subjectId)and(id = @id)
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_getTestPageByDegree]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t2 where (t2.subjectId=@subjectId)and(degree=@degree) order by t2.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_getTestPage]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t2 where (t2.subjectId=@subjectId) order by t2.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_getByRan]
	(   
		@subjectId bigint,
		@degree int,
		@total int,
		@kp bigint 
	)
AS
	/* SET NOCOUNT ON */
	if (@kp=-1)
	begin
	   if(@degree=-1)
	     SELECT  top (@total) * FROM t2 WHERE (subjectId=@subjectId) order by newid()
	   else
	     SELECT  top (@total) * FROM t2 WHERE (subjectId=@subjectId)and(degree=@degree) order by newid()
	end
	else
	begin
	   if(@degree=-1)
	     SELECT  top (@total) t2.* FROM t2
	      INNER JOIN
      WE_TestKeyWord ON t2.subjectId = WE_TestKeyWord.subjectId
WHERE (t2.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp) order by newid()
	   else
	     SELECT  top (@total) t2.* FROM t2 
	      INNER JOIN
      WE_TestKeyWord ON t2.subjectId = WE_TestKeyWord.subjectId
WHERE (t2.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp)and(degree=@degree) order by newid()
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_getbyid]
	(   
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	SELECT timu, testKey, degree, plainText, subjoinder, subjectId, updateTime, degree, comment
	FROM t2
	WHERE (subjectId=@subjectId)and(id = @id)
GO
/****** Object:  StoredProcedure [dbo].[we_t3_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_countByDegree]
	(
	@subjectId bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t3 where (subjectId=@subjectId)and(degree=@degree)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_update]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_update]
	(   @subjectId bigint,
	    @id bigint,
	    @plainText bit,
		@timu nvarchar(450),
		@subjoinder nvarchar(2000),
		@degree tinyint,
		@key xml,
		@comment nvarchar(100)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE t2
	SET timu = @timu, testKey = @key, plainText = @plainText, degree = @degree, 
	      subjoinder = @subjoinder, comment=@comment
	WHERE (subjectId = @subjectId) AND (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_insert]
	(@subjectId bigint,
		@plainText bit,
		@timu nvarchar(450),
		@subjoinder nvarchar(2000),
		@degree tinyint,
		@key xml,
		@comment nvarchar(100)
		
		
		
	)
AS
	/* SET NOCOUNT ON */
	declare @testId bigint
	SELECT @testId=id
	              FROM t2
	              WHERE (timu = @timu)and(subjectId=@subjectId)
	if @testId is null
	begin
	INSERT INTO t2
	      (timu, subjectId, testKey, plainText, degree,subjoinder, comment)
	VALUES (@timu,@subjectId,@key,@plainText,@degree,@subjoinder, @comment)
	 
	select @@IDENTITY--题目id SELECT @stid=@@IDENTITY--题目id
	end
	else
	select @testId
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_getTestPageByDegree]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t1 where (t1.subjectId=@subjectId)and(degree=@degree) order by t1.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_getTestPage]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t1 where (t1.subjectId=@subjectId) order by t1.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_getByRan]
	(   
		@subjectId bigint,
		@degree int,
		@total int,
		@kp bigint 
	)
AS
	/* SET NOCOUNT ON */
	if (@kp=-1)
	begin
	   if(@degree=-1)
	     SELECT  top (@total) * FROM t1 WHERE (subjectId=@subjectId) order by newid()
	   else
	     SELECT  top (@total) * FROM t1 WHERE (subjectId=@subjectId)and(degree=@degree) order by newid()
	end
	else
	begin
	   if(@degree=-1)
	     SELECT  top (@total) t1.* FROM t1
	      INNER JOIN
      WE_TestKeyWord ON t1.subjectId = WE_TestKeyWord.subjectId
WHERE (t1.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp) order by newid()
	   else
	     SELECT  top (@total) t1.* FROM t1 
	      INNER JOIN
      WE_TestKeyWord ON t1.subjectId = WE_TestKeyWord.subjectId
WHERE (t1.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp)and(degree=@degree) order by newid()
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_getbyid]
	(   
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	SELECT *
	FROM t1
	WHERE (subjectId=@subjectId)and(id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_countByDegree]
	(
	@subjectId bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t2 where (subjectId=@subjectId)and(degree=@degree)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_update]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_update]
	(   @subjectId bigint,
	    @id bigint,
	    @plainText bit,
		@timu nvarchar(450),
		@a nvarchar(450),
		@b nvarchar(450),
		@c nvarchar(450),
		@d nvarchar(450),
		@e nvarchar(450),
		@f nvarchar(450),
		@degree tinyint,
		@k1 varchar(6),
		@k2 varchar(6),
		@k3 varchar(6),
		@k4 varchar(6),
		
		@s1 decimal(3,2),
		@s2 decimal(3,2),
		@s3 decimal(3,2),
		@s4 decimal(3,2),
		@s0 decimal(3,2),
		@comment nvarchar(100)
		
	)
AS
	/* SET NOCOUNT ON */
	UPDATE t1
	SET timu = @timu, a = @a, b = @b, c = @c, d = @d, e = @e, f = @f, 
	k1 = @k1,k2 = @k2,k3 = @k3,k4 = @k4,s1 = @s1,s2 = @s2,s3 = @s3,s4 = @s4,s0 = @s0,
	plainText=@plainText,degree=@degree, comment=@comment
	WHERE (subjectid=@subjectId)and(id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_insert]
	(@subjectId bigint,
		@plainText bit,
		@timu nvarchar(450),
		@a nvarchar(450),
		@b nvarchar(450),
		@c nvarchar(450),
		@d nvarchar(450),
		@e nvarchar(450),
		@f nvarchar(450),
		@degree tinyint,
		@k1 varchar(6),
		@k2 varchar(6),
		@k3 varchar(6),
		@k4 varchar(6),
		
		@s1 decimal(3,2),
		@s2 decimal(3,2),
		@s3 decimal(3,2),
		@s4 decimal(3,2),
		@s0 decimal(3,2),
		@comment nvarchar(100)
		
		
		
	)
AS
	/* SET NOCOUNT ON */
	declare @testId bigint
	SELECT @testId=id
	              FROM t1
	              WHERE (timu = @timu)and(subjectId=@subjectId)
	if @testId is null
	begin
	INSERT INTO t1
	      (timu, subjectId, a, b, c, d, e, f, k1,k2,k3,k4,s1,s2,s3,s4,s0, plainText, degree, comment)
	VALUES (@timu,@subjectId,@a,@b,@c,@d,@e,@f,@k1,@k2,@k3,@k4,@s1,@s2,@s3,@s4,@s0,@plainText,@degree, @comment)
	 
	select @@IDENTITY--题目id SELECT @stid=@@IDENTITY--题目id
	end
	else
	select @testId
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_countByDegree]
	(
	@subjectId bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t1 where (subjectId=@subjectId)and(degree=@degree)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_update]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_update]
	(   @subjectId bigint,
	    @id bigint,
	    @plainText bit,
		@timu nvarchar(450),
		@a nvarchar(450),
		@b nvarchar(450),
		@c nvarchar(450),
		@d nvarchar(450),
		@e nvarchar(450),
		@f nvarchar(450),
		@degree tinyint,
		@sa decimal(3,2),
		@sb decimal(3,2),
		@sc decimal(3,2),
		@sd decimal(3,2),
		@se decimal(3,2),
		@sf decimal(3,2),
		@comment nvarchar(100)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE t0
	SET timu = @timu, a = @a, b = @b, c = @c, d = @d, e = @e, f = @f, SA= @sa, SB= @sb, SC= @sc, SD= @sd, SE= @se, SF= @sf, plainText=@plainText,degree=@degree, comment=@comment
	WHERE (subjectid=@subjectId)and(id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_insert]
	(@subjectId bigint,
		@plainText bit,
		@timu nvarchar(450),
		@a nvarchar(450),
		@b nvarchar(450),
		@c nvarchar(450),
		@d nvarchar(450),
		@e nvarchar(450),
		@f nvarchar(450),
		@degree tinyint,
		@sa decimal(3,2),
		@sb decimal(3,2),
		@sc decimal(3,2),
		@sd decimal(3,2),
		@se decimal(3,2),
		@sf decimal(3,2),
		@comment nvarchar(100)
	)
AS
	/* SET NOCOUNT ON */
	declare @testId bigint
	SELECT @testId=id
	              FROM t0
	              WHERE (timu = @timu)and(subjectId=@subjectId)
	if @testId is null
	begin
	INSERT INTO t0
	      (timu, subjectId, a, b, c, d, e, f, SA,SB,SC,SD,SE,SF, plainText, degree, comment)
	VALUES (@timu,@subjectId,@a,@b,@c,@d,@e,@f,@sa,@sb,@sc,@sd,@se,@sf,@plainText,@degree, @comment)
	 
	select @@IDENTITY--题目id SELECT @stid=@@IDENTITY--题目id
	end
	else
	select @testId
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPageByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_getTestPageByDegree]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t0 where (t0.subjectId=@subjectId)and(degree=@degree) order by t0.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPage]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_getTestPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t0 where (t0.subjectId=@subjectId) order by t0.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getByRan]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_getByRan]
	(   
		@subjectId bigint,
		@degree int,
		@total int,
		@kp bigint 
	)
AS
	/* SET NOCOUNT ON */
	if (@kp=-1)
	begin
	   if(@degree=-1)
	     SELECT  top (@total) * FROM t0 WHERE (subjectId=@subjectId) order by newid()
	   else
	     SELECT  top (@total) * FROM t0 WHERE (subjectId=@subjectId)and(degree=@degree) order by newid()
	end
	else
	begin
	   if(@degree=-1)
	     SELECT  top (@total) t0.* FROM t0
	      INNER JOIN
      WE_TestKeyWord ON t0.subjectId = WE_TestKeyWord.subjectId
WHERE (t0.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp) order by newid()
	   else
	     SELECT  top (@total) t0.* FROM t0 
	      INNER JOIN
      WE_TestKeyWord ON t0.subjectId = WE_TestKeyWord.subjectId
WHERE (t0.subjectId = @subjectId) AND (WE_TestKeyWord.keyWord = @kp)and(degree=@degree) order by newid()
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getbyid]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_getbyid]
	(   
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	SELECT *
	FROM t0
	WHERE (subjectId=@subjectId)and(id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_countByDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_countByDegree]
	
	(
	@subjectId bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	select @count=count(id) from t0 where (subjectId=@subjectId)and(degree=@degree)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_update]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_update]
	(   
	    @examid nvarchar(50),
	    @examiner nvarchar(20),
	    @timeLen int,
	    @testOrder tinyint,
	    @freeEnter bit,
	    
		@startTime smalldatetime,
		@endTime smalldatetime,
		
		
		
		@displayScore tinyint,
		@testsInOnePage bit,
		@lockPage bit,
		@enterLimitation int,
		@useLevelForResult bit
	)
AS
	/* SET NOCOUNT ON */
	UPDATE exam
	SET startTime = @startTime, ranOrder = @testOrder, endTime = @endTime, 
	      timeLen = @timeLen, freeEnter = @freeEnter, displayScore = @displayScore, 
	      lockPage = @lockPage, testsInOnePage = @testsInOnePage, enterLimitation = @enterLimitation, useLevelForResult = @useLevelForResult
	WHERE (examiner = @examiner) AND (id = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_myWaitExams]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_myWaitExams]
	(
		@examiner nvarchar(20),
		@compareTime datetime
	)
AS
	/* SET NOCOUNT ON */
	SELECT id, startTime, endTime, timeLen, random,freeEnter,displayScore
	FROM exam
	WHERE (examiner = @examiner) AND (startTime > @compareTime)
	ORDER BY startTime
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_getNew]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_getNew]
	
	(
	@nowdate datetime
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT TOP 10  CASE WHEN len(id) < 32 THEN id ELSE substring(id, 0, 30) 
      + '...' END as id, examiner, startTime, freeEnter, timeLen
	FROM exam
	WHERE (startTime > @nowdate) order by startTime desc
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_get]
	
	(
	@examId nvarchar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	
	SELECT examiner, startTime, endTime, timeLen, subjectId, freeEnter, testsInOnePage, 
	      lockPage, random, endCheck, static, ranOrder, displayScore, triggerTimer, 
	      enterLimitation,useLevelForResult
	FROM exam
	WHERE (id = @examId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_examinerRuningExams]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_examinerRuningExams]
	(
		@examiner nvarchar(20),
		@compareTime datetime
	)
AS
	/* SET NOCOUNT ON */
	SELECT id, startTime, endTime, timeLen, random,freeEnter,displayScore
	FROM exam
	WHERE (examiner = @examiner) AND (startTime <= @compareTime) AND (endTime > @compareTime)
	ORDER BY startTime
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_renameTitle]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exampaper_renameTitle]
	
	(
	@id bigint,
	@title nvarchar(450)
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE exam_paper
	SET title =@title
	WHERE (id = @id)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_insert]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exampaper_insert]
	
	(
	@subjectId bigint,
	@title nvarchar(450),
	@author nvarchar(50),

	@newId bigint output
	)
	
AS
	/* SET NOCOUNT ON */
	INSERT INTO exam_paper
	      (title, author, subjectId)
	VALUES (@title,@author,@subjectId)
	
	SET @newId=@@IDENTITY
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_getmypaperBySubject]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exampaper_getmypaperBySubject]
	
	(
	@author nvarchar(20),
	@subject bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT  id,subjectId,title, createTime
	FROM exam_paper
	WHERE (author = @author)and(subjectid=@subject) order by createTime desc
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_getmypaper]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exampaper_getmypaper]
	
	(
	@author nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT  id,subjectId,title,   createTime
	FROM exam_paper
	WHERE (author = @author)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_getbyid]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exampaper_getbyid]
	(
	
	@id bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT subjectId, author,title,  createTime
	FROM exam_paper
	WHERE (id = @id)
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_delete]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exampaper_delete]
	
	(
	
	@id bigint
	)
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM exam_paper
	WHERE (id = @id)
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exampaper_changeSubjectId]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exampaper_changeSubjectId]
	
	(
	@id bigint,
	@subjectId bigint,
	@author nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	UPDATE exam_paper
	SET subjectId = @subjectId
	WHERE (id = @id)and(author=@author)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_storeUsers_insert]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_storeUsers_insert]
	
	(
	@subjectId bigint,
	@userId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	if not exists(SELECT userId
	FROM WE_StoreUsers
	WHERE (subjectId = @subjectId)and(userId=@userId))
	INSERT INTO WE_StoreUsers
	      (subjectId, userId)
	VALUES (@subjectId,@userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_storeUsers_getBySubject]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_storeUsers_getBySubject]
	
	(
	@subjectId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT userId
	FROM WE_StoreUsers
	WHERE (subjectId = @subjectId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_storeUsers_deleteByUserId]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_storeUsers_deleteByUserId]
	
	(@subjectId bigint,
	@UserId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM WE_StoreUsers
	WHERE (UserId = @UserId)and(subjectId = @subjectId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_delete]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_delete]

	(
		@examid nvarchar(50),
		@examiner nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM exam
	WHERE (id = @examid) AND (examiner = @examiner)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_changeCheckState]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_changeCheckState]
	(
		@examid nvarchar(50),
		@examiner nvarchar(20),
		@endCheck bit
	)
AS
	/* SET NOCOUNT ON */
	UPDATE exam
	SET endCheck = @endCheck
	WHERE (id = @examid) AND (examiner = @examiner)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_add]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_add]
	(   @examid nvarchar(50),
		@examiner nvarchar(20),
		@timeLen int,
		@testOrder tinyint,
		
		@freeEnter bit,
		@startTime datetime,
		@endTime datetime,
		
		@subjectId bigint,
		@displayScore tinyint,

		@random tinyint,
		@testsInOnePage bit,
		@lockPage bit,
		@enterLimitation int,
		@useLevelForResult bit
	)
AS
	--SET NOCOUNT ON
	 if not exists(select id from exam where id=@examid)
	INSERT INTO exam
	      (id, examiner,  startTime, endTime,timeLen,freeEnter,subjectId,displayScore,random,ranOrder,testsInOnePage,lockPage,enterLimitation,useLevelForResult)
	VALUES (@examid,@examiner,@startTime,@endTime,@timeLen,@freeEnter,@subjectId,@displayScore,@random,@testOrder,@testsInOnePage,@lockPage,@enterLimitation,@useLevelForResult)
	
	
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_countByKeyPointDegree]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t1 INNER JOIN
	      WE_testsKeyWord ON t1.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId)and(degree=@degree) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_countByKeyPoint]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t1 INNER JOIN
	      WE_testsKeyWord ON t1.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_countByKeyPointDegree]
	
	(
	@subjectId bigint,
	@keyPoint bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t0 INNER JOIN
	      WE_testsKeyWord ON t0.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId)and(degree=@degree) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_countByKeyPoint]
	
	(
	@subjectId bigint,
	@keyPoint bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t0 INNER JOIN
	      WE_testsKeyWord ON t0.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_getTestPageByKeyPoint]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t0 INNER JOIN
	      WE_testsKeyWord ON t0.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t0.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint) order by t0.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t0_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_getTestPageByDegreeKeyPoint]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint tinyint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t0 INNER JOIN
	      WE_testsKeyWord ON t0.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t0.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint)and(degree=@degree) order by t0.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_getTestPageByKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t1 INNER JOIN
	      WE_testsKeyWord ON t1.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t1.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint) order by t1.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t1_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_getTestPageByDegreeKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint tinyint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t1 INNER JOIN
	      WE_testsKeyWord ON t1.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t1.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint)and(degree=@degree) order by t1.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_getTestPageByKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t2 INNER JOIN
	      WE_testsKeyWord ON t2.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t2.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint) order by t2.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_getTestPageByDegreeKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint tinyint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t2 INNER JOIN
	      WE_testsKeyWord ON t2.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t2.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint)and(degree=@degree) order by t2.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_countByKeyPointDegree]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t3 INNER JOIN
	      WE_testsKeyWord ON t3.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId)and(degree=@degree) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_countByKeyPoint]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t3 INNER JOIN
	      WE_testsKeyWord ON t3.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_countByKeyPointDegree]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t2 INNER JOIN
	      WE_testsKeyWord ON t2.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId)and(degree=@degree) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t2_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_countByKeyPoint]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t2 INNER JOIN
	      WE_testsKeyWord ON t2.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_countByKeyPointDegree]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t5 INNER JOIN
	      WE_testsKeyWord ON t5.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId)and(degree=@degree) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_countByKeyPoint]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t5 INNER JOIN
	      WE_testsKeyWord ON t5.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_countByKeyPointDegree]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_countByKeyPointDegree]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@degree tinyint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t4 INNER JOIN
	      WE_testsKeyWord ON t4.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId)and(degree=@degree) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_countByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_countByKeyPoint]
	(
	@subjectId bigint,
	@keyPoint bigint,
	@count bigint output
	)
	
AS
	/* SET NOCOUNT ON */ 
	
	
	SELECT @count=count(id)
	FROM t4 INNER JOIN
	      WE_testsKeyWord ON t4.id = WE_testsKeyWord.testId
	WHERE (subjectId=@subjectId) and (WE_testsKeyWord.testClass = 0) AND 
	      (WE_testsKeyWord.keyWordId = @keyPoint)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_getTestPageByKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t4 INNER JOIN
	      WE_testsKeyWord ON t4.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t4.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint) order by t4.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t4_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_getTestPageByDegreeKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint tinyint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t4 INNER JOIN
	      WE_testsKeyWord ON t4.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t4.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint)and(degree=@degree) order by t4.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_getTestPageByKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t3 INNER JOIN
	      WE_testsKeyWord ON t3.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t3.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint) order by t3.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t3_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_getTestPageByDegreeKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint tinyint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t3 INNER JOIN
	      WE_testsKeyWord ON t3.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t3.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint)and(degree=@degree) order by t3.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[in_myGroup]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.in_myGroup    Script Date: 2006-5-19 14:45:32 ******/
CREATE PROCEDURE [dbo].[in_myGroup]
	(
		@owner nvarchar(20),
		@groupName nvarchar(20),
		@individual nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	if not exists(select * from mygroup where (owner=@owner)and(groupName=@groupName)and(individual=@individual))
	if EXISTS(select id from [user] where id=@individual)
	INSERT INTO myGroup
	      (owner, groupName, individual)
	VALUES (@owner, @groupName, @individual)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_exam_triggerTimer]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_exam_triggerTimer    Script Date: 2006-5-19 14:45:40 ******/
CREATE PROCEDURE [dbo].[up_exam_triggerTimer]

	(
		@examid nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	UPDATE exam
	SET triggerTimer = 0
	WHERE (id = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_exam_static]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_exam_static    Script Date: 2006-5-19 14:45:40 ******/
CREATE PROCEDURE [dbo].[up_exam_static]

	(
		@examid nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	UPDATE exam
	SET static = 1,triggerTimer = 1
	WHERE (id = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_myGroup_groupName]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_myGroup_groupName    Script Date: 2006-5-19 14:45:40 ******/
CREATE PROCEDURE [dbo].[up_myGroup_groupName]
	(
		@owner nvarchar(20),
		@groupName nvarchar(20),
		@newGroupName nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE myGroup
	SET groupName = @newGroupName
	WHERE (groupName = @groupName) AND (owner = @owner)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[in_sms]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.in_sms    Script Date: 2006-5-19 14:45:32 ******/
CREATE PROCEDURE [dbo].[in_sms]
	(
		@uid nvarchar(20),
		@title nvarchar(20),
		@msg nvarchar(900),
		@fromUid nvarchar(20)
	)
AS
	 SET NOCOUNT ON 
	INSERT INTO sms
	      (touid,title, msg, fromUid)
	VALUES (@uid,@title,@msg, @fromUid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[in_skwusers_accordingGroup]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.in_skwusers_accordingGroup    Script Date: 2006-5-19 14:45:32 ******/
CREATE PROCEDURE [dbo].[in_skwusers_accordingGroup]
	(
		@skwid nvarchar(50),
		
		@owner nvarchar(20),
		@groupName nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	DECLARE individual_cursor CURSOR LOCAL FOR select individual from mygroup where (owner=@owner)and(groupName=@groupName)
	OPEN individual_cursor
    declare @individualId nvarchar(20)
    FETCH NEXT FROM individual_cursor into @individualId
    WHILE @@FETCH_STATUS = 0
      BEGIN
         declare @find bit
         select @find=count(*) from shwusers where (schoolworkid=@skwid)and(userid=@individualId)
         if (@find=0)
           begin
            INSERT INTO shwusers
	      (schoolworkid,score,userid)values(@skwid,0,@individualId)
           
           end
         
         FETCH NEXT FROM individual_cursor into @individualId
      end
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_sms_expired]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_sms_expired    Script Date: 2006-5-19 14:45:26 ******/
CREATE PROCEDURE [dbo].[dl_sms_expired]
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM sms
	WHERE (sendTime < DATEADD(m,-1,GETDATE()))
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_sms]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_sms    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_sms]
	(
		@id bigint,
		@uid nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM sms
	WHERE (id = @id) and (touid=@uid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_myGroup_user]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_myGroup_user    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[dl_myGroup_user]
	(
		@owner nvarchar(20),
		@groupName nvarchar(20),
		@individual nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM myGroup
	WHERE (owner = @owner) AND (groupName = @groupName) and(individual=@individual)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_myGroup]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.dl_myGroup    Script Date: 2006-5-19 14:45:30 ******/
CREATE PROCEDURE [dbo].[dl_myGroup]
	(
		@owner nvarchar(20),
		@groupName nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	DELETE FROM myGroup
	WHERE (owner = @owner) AND (groupName = @groupName)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_sms_myall]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_sms_myall    Script Date: 2006-5-19 14:45:37 ******/
CREATE PROCEDURE [dbo].[sl_sms_myall]
	(
		@uid nvarchar(20)
	)
AS
	 SET NOCOUNT ON 
	SELECT id, toUid, ifRead, fromUid, sendTime, title
	FROM sms
	WHERE (toUid = @uid)
	ORDER BY ifRead, sendTime DESC
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_sms_byRead]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_sms_byRead    Script Date: 2006-5-19 14:45:37 ******/
CREATE PROCEDURE [dbo].[sl_sms_byRead]
	(
		@uid nvarchar(20)
	)
AS
	 SET NOCOUNT ON 
	SELECT id, touid, ifRead, fromUid, sendTime, title
	FROM sms
	WHERE (touid = @uid) AND (ifRead = 1)
	ORDER BY sendTime DESC
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_sms_all]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_sms_all    Script Date: 2006-5-19 14:45:37 ******/
CREATE PROCEDURE [dbo].[sl_sms_all]
	(   @id bigint,
		@uid nvarchar(20)
	)
AS
	 SET NOCOUNT ON 
	 declare @read bit
	
	SELECT touid, fromUid, sendTime, title,msg
	FROM sms
	WHERE (id= @id) AND (touid = @uid)
	UPDATE sms
	SET ifRead = 1 WHERE (id= @id) AND (touid = @uid) and (ifRead =0)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_sms]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_sms    Script Date: 2006-5-19 14:45:37 ******/
CREATE PROCEDURE [dbo].[sl_sms]
	(
		@uid nvarchar(20)
	)
AS
	 SET NOCOUNT ON 
	SELECT id, touid, ifRead, fromUid, sendTime, title
	FROM sms
	WHERE (touid = @uid) AND (ifRead = 0)
	ORDER BY sendTime DESC
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_myGroup_usersList]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_myGroup_usersList    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_myGroup_usersList]
	(
		@_RecordsCount bigint output,
		@_PageSize int=0,
		@_PageGroupIndex int=0,		
		@_RecordStartId nvarchar(50)='',
		@_RecordEndId nvarchar(50)='',
		@_IsNavigation bit= 0,
		
		@owner nvarchar(20),
		@groupName nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	if (@_IsNavigation=1)
	begin
	declare @indextable table(id int identity(1,1),nid nvarchar(20))
	
      
           insert into @indextable(nid) select individual from myGroup where (owner=@owner) and (groupName=@groupName) order by individual desc
       
    
    select @_RecordsCount=count(id) from @indextable
    
    declare @id1 bigint
    declare @id2 bigint
    declare @id3 bigint
    declare @id4 bigint
    declare @id5 bigint
    declare @id6 bigint
    declare @id7 bigint
    declare @id8 bigint
    declare @id9 bigint
    declare @id10 bigint
    declare @id11 bigint
    set @id1=1+(10*@_PageSize)*@_PageGroupIndex
    set @id2=@id1+@_PageSize
    set @id3=@id2+@_PageSize
    set @id4=@id3+@_PageSize
    set @id5=@id4+@_PageSize
    set @id6=@id5+@_PageSize
    set @id7=@id6+@_PageSize
    set @id8=@id7+@_PageSize
    set @id9=@id8+@_PageSize
    set @id10=@id9+@_PageSize
    set @id11=@id10+@_PageSize
    select nid from @indextable where (id=@id1) or (id=@id2) or (id=@id3) or (id=@id4) or (id=@id5) or (id=@id6) or (id=@id7) or (id=@id8) or (id=@id9) or (id=@id10) or (id=@id11)
    end
    else
    begin
     
           select individual from myGroup where (owner=@owner) and (groupName=@groupName)and (individual<=@_RecordStartId) and (individual>@_RecordEndId)  order by individual desc
         
         
       
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_myGroup]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_myGroup    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_myGroup]
	(
		@owner nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	--
	SELECT DISTINCT groupName
	FROM myGroup
	WHERE (owner = @owner)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_triggerTimer]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_exam_triggerTimer    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_exam_triggerTimer]
/*
	(
		@parameter1 datatype = default value,
		@parameter2 datatype OUTPUT
	)
*/
AS
	/* SET NOCOUNT ON */
	SELECT top 100 id AS examid
	FROM exam
	WHERE (triggerTimer = 1) and (static = 1)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_finish]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_exam_finish    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_exam_finish]
	(
	 @endTime smalldatetime
	)
AS
	/* SET NOCOUNT ON */
	SELECT TOP 20 id, startTime,endTime,random
	FROM exam
	WHERE (static=1)and(endTime < @endTime) AND (displayScore =2)
	ORDER BY endTime DESC
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_examid_end]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_exam_examid_end    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_exam_examid_end]
	(
		@examer nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT id as examid,startTime, endTime,random
	FROM exam where (static=1) and (examiner = @examer)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_examid]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_exam_examid    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_exam_examid]
	(
		@examer nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT id AS examid,  startTime,  endTime, random, endCheck
	FROM exam
	WHERE (static = 0) AND (examiner = @examer) AND (endTime < GETDATE())
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_exam_allFinish]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_exam_allFinish    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[sl_exam_allFinish]
	
AS
	/* SET NOCOUNT ON */
	SELECT id,startTime
	FROM exam
	WHERE (endTime < getdate()) and (displayScore=1)
	ORDER BY endTime DESC
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_testsKeyWord_insert]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_testsKeyWord_insert]
	
	(
	@testId bigint,
	@testClass int,
	@keyPointId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	if not exists(select * from WE_testsKeyWord where (testId = @testid) AND (testClass = @testclass) AND (keyWordId = @keyPointId))
	INSERT INTO WE_testsKeyWord
	      (testId, testClass, keyWordId)
	VALUES (@testId,@testClass,@keyPointId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_testsKeyWord_getByTest]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_testsKeyWord_getByTest]
	
	(
	@testId bigint,
	@testClass int
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT WE_testsKeyWord.keyWordId as keyPointId, WE_TestKeyWord.keyWord as keyPoint
	FROM WE_testsKeyWord INNER JOIN
	      WE_TestKeyWord ON WE_testsKeyWord.keyWordId = WE_TestKeyWord.id
	WHERE (WE_testsKeyWord.testId = @testid) AND 
	      (WE_testsKeyWord.testClass = @testclass)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_testsKeyWord_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_testsKeyWord_delete]
	
	(
	@testId bigint,
	@testClass int
	)
	
AS
	/* SET NOCOUNT ON */
	DELETE FROM WE_testsKeyWord
	WHERE (testId = @testid) AND (testClass = @testclass)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPageByKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_getTestPageByKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint bigint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t5 INNER JOIN
	      WE_testsKeyWord ON t5.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t5.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint) order by t5.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_getTestPageByDegreeKeyPoint]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_getTestPageByDegreeKeyPoint]
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord bigint,
	
	@subjectId bigint,
	@keyPoint tinyint,
	@degree tinyint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from t5 INNER JOIN
	      WE_testsKeyWord ON t5.id = WE_testsKeyWord.testId where  (WE_testsKeyWord.testClass = 0) AND (t5.subjectId=@subjectId)and(WE_testsKeyWord.keyWordId=@keyPoint)and(degree=@degree) order by t5.id desc) a  order by a.id) b order by b.id desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getUsersByRoleForDepart]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_userRoles_getUsersByRoleForDepart]
	(
	@roleId int,
	@departId bigint
	)
	
AS
	/* SET NOCOUNT ON */ 
	SELECT   userRoles.id, userRoles.userid, [user].userName
	FROM      userRoles INNER JOIN
	                [user] ON userRoles.userid = [user].id
	WHERE   (userRoles.roleid = @roleId) AND ([user].departId = @departId) 
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getUserRangeByRole]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_userRoles_getUserRangeByRole]
	(
	@userId nvarchar(20),
	@roleId int
	)
	
AS
	/* SET NOCOUNT ON */ 
	SELECT     range
	FROM         userRoles
	WHERE     (userId = @userId)and(roleId=@roleId) 
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getUserByRole]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_userRoles_getUserByRole]
	(
	@roleId int,
	@range bigint
	)
	
AS
	/* SET NOCOUNT ON */ 
	SELECT     Id, userId
	FROM         userRoles
	WHERE     (roleId = @roleId)and(range=@range) 
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_getRoles]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_userRoles_getRoles]
	(
	@userId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */ 
	SELECT     Id, roleId,range
	FROM         userRoles
	WHERE     (userId = @userid) order by roleId
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_delRole]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_userRoles_delRole]
	
	(@userId nvarchar(20),
	@roleId int,
	@range bigint
	)
	
AS
	/* SET NOCOUNT ON */
	
	DELETE FROM userRoles
	WHERE (userId = @userId) AND (RoleId = @RoleId) AND (range = @Range)
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_delByTargetId]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_userRoles_delByTargetId]
	
	(
	@roleId int,
	@range bigint
	)
	
AS
	/* SET NOCOUNT ON */
	
	DELETE FROM userRoles
	WHERE (RoleId =@roleId) AND (range = @Range)
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_userRoles_addRole]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_userRoles_addRole]
	(@userId nvarchar(20),
	@roleId int,
	@range bigint
	)
	
AS
	/* SET NOCOUNT ON */
	if not exists(
	SELECT *
	FROM userRoles
	WHERE (userId = @userId) AND (RoleId = @RoleId) AND (range = @Range))
	INSERT INTO userRoles
	      (RoleId, range,userId)
	VALUES (@RoleId,@Range,@userId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_t5_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t5_delete]
	(
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	if exists(select id from t5 WHERE (id = @id)and(@subjectId=@subjectId))
	begin
	DELETE FROM t5
	WHERE (id = @id)
	exec we_testsKeyWord_delete @testId=@id,@testClass=5
	end
	
	return
GO
/****** Object:  StoredProcedure [dbo].[sl_group_myTask]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_group_myTask    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_group_myTask]
	(
		
		@userid nvarchar(20)
	)
AS
	SET NOCOUNT ON 
	SELECT [group].examid
	FROM [group] INNER JOIN
	      exam ON [group].examid = exam.id
	WHERE ([group].userid = @userid) AND (exam.endCheck = 0)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_group_groupNo_byExamId]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_group_groupNo_byExamId    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_group_groupNo_byExamId]
	(
		@examid nvarchar(50)
	)
AS
	 SET NOCOUNT ON 
	SELECT max (groupNo)
	FROM [group]
	WHERE (examid = @examid)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT5_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT5_frequentKey    Script Date: 2006-5-19 14:45:36 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT5_frequentKey]

	(
		@examid nvarchar(50),
		@testid bigint
	)

AS
	/* SET NOCOUNT ON */
	select top 10 eKey,keyCount from (select eKey,count(*) as keyCount from examinee_key_t5 where (examid=@examId and testId=@testId) group by eKey ) b order by keyCount desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT4_groupNo    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT4_groupNo]

	(
		@examid nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	SELECT DISTINCT testId, groupNo
	FROM examinee_key_t4
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT4_count    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT4_count]
	(
		@examid nvarchar(50),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(testId)
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (groupNo = @groupno)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_checkedPrev]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT4_checkedPrev    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT4_checkedPrev]
	(
		@examid nvarchar(50),
		@SN int,
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	
	declare @testId varchar(10)
	SELECT top 1 @testId=testid
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN <@sn) 
	ORDER BY sn desc
	
	
	SELECT TOP 10 examineeId, testId, score, checker, eKey,sn
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN < @SN)  AND (testId = @testId)
	ORDER BY SN DESC
	
   
   
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_checkedNext]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT4_checkedNext    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT4_checkedNext]
	(
		@examid nvarchar(50),
		@SN int,
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @testId varchar(10)
	SELECT top 1 @testId=testid
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN >@sn) 
	ORDER BY sn 
	
	
	SELECT TOP 10 examineeId, testId, score, checker, eKey,sn
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (checked = 1) AND (testId = @testId) AND (checker = @checker) AND (SN > @SN) AND 
	      (NOT (SN IS NULL))
	ORDER BY SN
	
   
   
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT4_checkedCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT4_checkedCount    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT4_checkedCount]
	(
		@examid nvarchar(50),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(testId)
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (groupNo = @groupno) AND (checked=1)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT3_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT3_frequentKey    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT3_frequentKey]

	(
		@examid nvarchar(50),
		@testid bigint
	)

AS
	/* SET NOCOUNT ON */
	select top 10 eKey,keyCount from (select eKey,count(*) as keyCount from examinee_key_t3 where (examid=@examId and testId=@testId) group by eKey ) b order by keyCount desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT3_ek]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sl_examineeKeyT3_ek]
	(
	@examid nvarchar(50),
	@examineeId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */ 
		declare @tem_table table(testId bigint PRIMARY KEY)
	
	insert into @tem_table(testId)
	SELECT     testId
	FROM         standard_key_t3
	WHERE     (examid = @examid)
	
	delete @tem_table where testId in (
	SELECT     testId
	FROM         examinee_key_t3
	WHERE     (examid = @examid) AND (examineeId = @examineeId) AND (score > 0)
	)
	
	SELECT     testId
	FROM         @tem_table
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT2_groupNo    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT2_groupNo]

	(
		@examid nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	SELECT DISTINCT testId, groupNo
	FROM examinee_key_t2
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT2_frequentKey    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT2_frequentKey]

	(
		@examid nvarchar(50),
		@testid bigint,
		@addr int
	)

AS
	/* SET NOCOUNT ON */
	select top 10 eKey,keyCount from (select eKey,count(*) as keyCount from examinee_key_t2 where (examid=@examId and testId=@testId and insideaddr=@addr) group by eKey ) b order by keyCount desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_count]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT2_count    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT2_count]
	(
		@examid nvarchar(50),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	declare @table table(examineeId nvarchar(20),testId bigint)
	insert into @table(examineeId,testId)
	SELECT DISTINCT examineeId,testId
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (groupNo = @groupno)
	
	select count(examineeid) from @table
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_checkedPrev]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT2_checkedPrev    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT2_checkedPrev]
	(
		@examid nvarchar(50),
		@SN int,
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @testId varchar(10)
SELECT top 1 @testId=testid
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN <@sn) 
	order by sn desc
	
   declare @table table(sn smallint)
	insert into @table(sn)
	SELECT DISTINCT top 10 sn
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN <@sn) 
	ORDER BY sn  desc
	
	SELECT examineeId, testId, insideAddr, score, checker, eKey,sn
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (testId = @testId) AND (SN in (select sn from @table)) 
	ORDER BY sn
   
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_checkedNext]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT2_checkedNext    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT2_checkedNext]
	(
		@examid nvarchar(50),
		@SN int,
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @testId varchar(10)
	SELECT top 1 @testId=testid
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN >@sn) 
	ORDER BY sn 
	
	declare @table table(sn smallint)
	insert into @table(sn)
	SELECT DISTINCT top 10 sn
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN >@sn) 
	ORDER BY sn
	
	
	SELECT examineeId, testId, insideAddr, score, checker, eKey,sn
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checked = 1) AND (testId = @testId) AND (checker = @checker) AND (SN in (select sn from @table)) 
	ORDER BY sn
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT2_checkedCount]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT2_checkedCount    Script Date: 2006-5-19 14:45:27 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT2_checkedCount]
	(
		@examid nvarchar(50),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	
	declare @table table(examineeId nvarchar(20),testId bigint)
	insert into @table(examineeId,testId)
	SELECT DISTINCT examineeId,testId
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (groupNo = @groupno) AND (checked=1)
	
	select count(examineeid) from @table
	

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT1_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT1_frequentKey    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT1_frequentKey]

	(
		@examid nvarchar(50),
		@testid bigint
	)

AS
	/* SET NOCOUNT ON */
	select top 10 eKey,keyCount from (select eKey,count(*) as keyCount from examinee_key_t1 where (examid=@examId and testId=@testId) group by eKey ) b order by keyCount desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT1_ek]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sl_examineeKeyT1_ek]
	(
	@examid nvarchar(50),
	@examineeId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */ 
	declare @tem_table table(testId bigint PRIMARY KEY)
	
	insert into @tem_table(testId)
	SELECT     testId
	FROM         standard_key_t1
	WHERE     (examid = @examid)
	
	delete @tem_table where testId in (
	SELECT     testId
	FROM         examinee_key_t1
	WHERE     (examid = @examid) AND (examineeId = @examineeId) AND (score > 0)
	)
	
	SELECT     testId
	FROM         @tem_table
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT0_frequentKey]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.sl_examineeKeyT0_frequentKey    Script Date: 2006-5-19 14:45:35 ******/
CREATE PROCEDURE [dbo].[sl_examineeKeyT0_frequentKey]

	(
		@examid nvarchar(50),
		@testid bigint
	)

AS
	/* SET NOCOUNT ON */
	select top 10 eKey,keyCount from (select eKey,count(*) as keyCount from examinee_key_t0 where (examid=@examId and testId=@testId) group by eKey ) b order by keyCount desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[sl_examineeKeyT0_ek]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sl_examineeKeyT0_ek]
	
	(
	@examid nvarchar(50),
	@examineeId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */ 
	declare @tem_table table(testId bigint PRIMARY KEY)
	
	insert into @tem_table(testId)
	SELECT     testId
	FROM         standard_key_t0
	WHERE     (examid = @examid)
	
	delete @tem_table where testId in (
	SELECT     testId
	FROM         examinee_key_t0
	WHERE     (examid = @examid) AND (examineeId = @examineeId) AND (score > 0)
	)
	
	SELECT     testId
	FROM         @tem_table
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t5]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.fun_testScorePercent_t5    Script Date: 2006-5-19 14:45:32 ******/
CREATE PROCEDURE [dbo].[fun_testScorePercent_t5]

	(
		@examId nvarchar(50)
	)

AS

    declare @totalExaminee int
    SELECT @totalExaminee=COUNT(score)
	FROM chengji
	WHERE (examid = @examid) AND (times >= 1)
	
	declare @tem_table table(testId bigint PRIMARY KEY,score decimal(38,2))
	
	insert into @tem_table(testId,score)	
	SELECT testId,sum(score) AS Score
	FROM examinee_key_t5
	WHERE (examid = @examId)
	GROUP BY testId
	
	declare @temTable table(testId bigint PRIMARY KEY,fullscore decimal(38,2))
	
	insert into @temTable(testId,fullscore)
	SELECT testId, sum(score) AS fullscore
	FROM standard_key_t5
	WHERE (examid = @examId)
	GROUP BY testId
	
	SELECT t1.testId, (score/(@totalExaminee*fullscore)) as testScorePercent 
	FROM @temTable as t1 left JOIN @tem_table as t2 ON t1.testId = t2.testId order by score
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t4]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.fun_testScorePercent_t4    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[fun_testScorePercent_t4]

	(
		@examId nvarchar(50)
	)

AS

    declare @totalExaminee int
    SELECT @totalExaminee=COUNT(score)
	FROM chengji
	WHERE (examid = @examid) AND (times >= 1)
	
	declare @tem_table table(testId bigint PRIMARY KEY,score decimal(38,2))
	
	insert into @tem_table(testId,score)	
	SELECT testId,sum(score) AS Score
	FROM examinee_key_t4
	WHERE (examid = @examId)
	GROUP BY testId
	
	declare @temTable table(testId bigint PRIMARY KEY,fullscore decimal(38,2))
	
	insert into @temTable(testId,fullscore)
	SELECT testId, sum(score) AS fullscore
	FROM standard_key_t4
	WHERE (examid = @examId)
	GROUP BY testId
	
	SELECT t1.testId, (score/(@totalExaminee*fullscore)) as testScorePercent 
	FROM @temTable as t1 left JOIN @tem_table as t2 ON t1.testId = t2.testId order by score
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t3]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.fun_testScorePercent_t3    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[fun_testScorePercent_t3]

	(
		@examId nvarchar(50)
	)

AS

    declare @totalExaminee int
    SELECT @totalExaminee=COUNT(score)
	FROM chengji
	WHERE (examid = @examid) AND (times >= 1)
	
	declare @tem_table table(testId bigint PRIMARY KEY,score decimal(38,2))
	
	insert into @tem_table(testId,score)	
	SELECT testId,sum(score) AS Score
	FROM examinee_key_t3
	WHERE (examid = @examId)
	GROUP BY testId
	
	declare @temTable table(testId bigint PRIMARY KEY,fullscore decimal(38,2))
	
	insert into @temTable(testId,fullscore)
	SELECT testId, sum(score) AS fullscore
	FROM standard_key_t3
	WHERE (examid = @examId)
	GROUP BY testId
	
	SELECT t1.testId, (score/(@totalExaminee*fullscore)) as testScorePercent 
	FROM @temTable as t1 left JOIN @tem_table as t2 ON t1.testId = t2.testId order by score
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t2]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.fun_testScorePercent_t2    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[fun_testScorePercent_t2]

	(
		@examId nvarchar(50)
	)

AS

    declare @totalExaminee int
    SELECT @totalExaminee=COUNT(score)
	FROM chengji
	WHERE (examid = @examid) AND (times >= 1)
	
	declare @tem_table table(testId bigint PRIMARY KEY,score decimal(38,2))
	
	insert into @tem_table(testId,score)	
	SELECT testId,sum(score) AS Score
	FROM examinee_key_t2
	WHERE (examid = @examId)
	GROUP BY testId
	
	declare @temTable table(testId bigint PRIMARY KEY,fullscore decimal(38,2))
	
	insert into @temTable(testId,fullscore)
	SELECT testId, sum(score) AS fullscore
	FROM standard_key_t2
	WHERE (examid = @examId)
	GROUP BY testId
	
	SELECT t1.testId, (score/(@totalExaminee*fullscore)) as testScorePercent 
	FROM @temTable as t1 left JOIN @tem_table as t2 ON t1.testId = t2.testId order by score
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t1]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.fun_testScorePercent_t1    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[fun_testScorePercent_t1]

	(
		@examId nvarchar(50)
	)

AS

    declare @totalExaminee int
    SELECT @totalExaminee=COUNT(score)
	FROM chengji
	WHERE (examid = @examid) AND (times >= 1)
	
	declare @tem_table table(testId bigint PRIMARY KEY,score decimal(38,2))
	
	insert into @tem_table(testId,score)	
	SELECT testId,sum(score) AS Score
	FROM examinee_key_t1
	WHERE (examid = @examId)
	GROUP BY testId
	
	declare @temTable table(testId bigint PRIMARY KEY,fullscore decimal(38,2))
	
	insert into @temTable(testId,fullscore)
	SELECT testId, sum(score) AS fullscore
	FROM standard_key_t1
	WHERE (examid = @examId)
	GROUP BY testId
	
	SELECT t1.testId, (score/(@totalExaminee*fullscore)) as testScorePercent 
	FROM @temTable as t1 left JOIN @tem_table as t2 ON t1.testId = t2.testId order by score
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_testScorePercent_t0]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.fun_testScorePercent_t0    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[fun_testScorePercent_t0]

	(
		@examId nvarchar(50)
	)

AS

    declare @totalExaminee int
    SELECT @totalExaminee=COUNT(score)
	FROM chengji
	WHERE (examid = @examid) AND (times >= 1)
	
	declare @tem_table table(testId bigint PRIMARY KEY,score decimal(38,2))
	
	insert into @tem_table(testId,score)	
	SELECT testId,sum(score) AS Score
	FROM examinee_key_t0
	WHERE (examid = @examId)
	GROUP BY testId
	
	declare @temTable table(testId bigint PRIMARY KEY,fullscore decimal(38,2))
	
	insert into @temTable(testId,fullscore)
	SELECT testId, sum(score) AS fullscore
	FROM standard_key_t0
	WHERE (examid = @examId)
	GROUP BY testId
	
	SELECT t1.testId, (score/(@totalExaminee*fullscore)) as testScorePercent 
	FROM @temTable as t1 left JOIN @tem_table as t2 ON t1.testId = t2.testId order by score
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_delExamineesKey]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[fun_delExamineesKey]

	(
		@examid nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	DELETE FROM examinee_key_t0
	WHERE (examid = @examid)
	DELETE FROM examinee_key_t1
	WHERE (examid = @examid)
	DELETE FROM examinee_key_t2
	WHERE (examid = @examid)
	DELETE FROM examinee_key_t3
	WHERE (examid = @examid)
	DELETE FROM examinee_key_t4
	WHERE (examid = @examid)
	DELETE FROM examinee_key_t5
	WHERE (examid = @examid)
	DELETE FROM examinee_key_t10
	WHERE (examid = @examid)
	DELETE FROM examinee_key_t11
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[fun_delExamineeKey]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.fun_delExamineeKey    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[fun_delExamineeKey]

	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)

AS
	/* SET NOCOUNT ON */
	DELETE FROM examinee_key_t0
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t1
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t2
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t3
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t4
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t5
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t10
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t11
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[examrenshu]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.examrenshu    Script Date: 2006-5-19 14:45:31 ******/
CREATE PROCEDURE [dbo].[examrenshu]
	(
		@examid nvarchar(50),
		@renshu int OUTPUT
	)
AS
	/* SET NOCOUNT ON */
	SELECT @renshu=COUNT(*)
	FROM chengji
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[dl_user_DeleteUser]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[dl_user_DeleteUser]
	
	(
	  @userId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
DELETE FROM chengji
WHERE     (examinee = @userId)
	DELETE FROM [user]
	WHERE (id = @userId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_checkerGroup_in]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_checkerGroup_in]
	(
		@examid nvarchar(50),
		@userid nvarchar(20),
		@groupno int
	)
AS
	/* SET NOCOUNT ON */
	INSERT INTO [group]
	      (examid, userid, groupNo)
	VALUES (@examid, @userid, @groupno)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_checkerGroup_getGroup]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_checkerGroup_getGroup]
	(
		@examid nvarchar(50),
		@userid nvarchar(20)
	)
AS
	SET NOCOUNT ON 
	SELECT groupNo
	FROM [group]
	WHERE (examid = @examid) AND (userid = @userid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_checkerGroup_getByExamId]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_checkerGroup_getByExamId]
	(
		@examid nvarchar(50)
	)
AS
	 SET NOCOUNT ON 
	SELECT *
	FROM [group]
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_chcekerGroup_delByExamid]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_chcekerGroup_delByExamid]
(@examid nvarchar(50)) AS 
DELETE FROM [group]	WHERE (examid = @examid)

Return
GO
/****** Object:  StoredProcedure [dbo].[up_examineeKeyT4_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_examineeKeyT4_groupNo    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[up_examineeKeyT4_groupNo]
	(
		@examid nvarchar(50),
		@testId varchar(10),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	UPDATE examinee_key_t4
	SET groupNo = @groupNo
	WHERE (examid = @examid) AND (testId = @testId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_examineeKeyT2_score_checker]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_examineeKeyT2_score_checker    Script Date: 2006-5-19 14:45:40 ******/
CREATE PROCEDURE [dbo].[up_examineeKeyT2_score_checker]

	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
		
		--@groupNo smallint,
		@score decimal(5,2),
		@checker nvarchar(20),@addr smallint
	)

AS
	/* SET NOCOUNT ON */
	declare @groupNo smallint--阅卷人所在的小组
	select top 1 @groupNo=groupNo from [group] where examid=@examid and userid=@checker
	if @groupNo=null RETURN
	--declare @addr smallint
	--select top 1 @addr=insideAddr from examinee_key_t2 where (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId) order by insideAddr
	if @addr=null return
	declare @PSN int
	select top 1 @PSN=SN from examinee_key_t2 where (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId)
	if @PSN is null
	begin
	declare @SN int
	SELECT top 1  @SN=SN
	FROM examinee_key_t2
	WHERE (examid = @examid) AND(checker = @checker)
	ORDER BY SN DESC
	if @SN is null set @SN=0
	UPDATE examinee_key_t2
	SET score = @score
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId) AND 
	      (insideAddr = @addr) AND (groupNo = @groupNo)
	 UPDATE examinee_key_t2
	SET SN=@SN+1, checker = @checker,checked=1
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId) AND 
	      (groupNo = @groupNo)
	end
	else
	begin
	UPDATE examinee_key_t2
	SET score = @score
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId) AND 
	      (insideAddr = @addr) AND (groupNo = @groupNo)    
	UPDATE examinee_key_t2
	SET checker = @checker,checked=1
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId) AND 
	       (groupNo = @groupNo)  
	end  
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_examineeKeyT2_groupNo]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_examineeKeyT2_groupNo    Script Date: 2006-5-19 14:45:28 ******/
CREATE PROCEDURE [dbo].[up_examineeKeyT2_groupNo]
	(
		@examid nvarchar(50),
		@testId varchar(10),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	UPDATE examinee_key_t2
	SET groupNo = @groupNo
	WHERE (examid = @examid) AND (testId = @testId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[up_chengji_ipToAll]    Script Date: 11/04/2010 16:14:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.up_chengji_ipToAll    Script Date: 2006-5-19 14:45:39 ******/
CREATE PROCEDURE [dbo].[up_chengji_ipToAll]
	(
		@examid nvarchar(50),
		@ip1 varchar(30),
		@ip2 varchar(30)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE chengji
	SET ip1 = @ip1, ip2 = @ip2,ip=null
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[in_chengji_filter]    Script Date: 11/04/2010 16:14:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/****** Object:  Stored Procedure dbo.in_chengji_filter    Script Date: 2006-5-19 14:45:32 ******/
CREATE PROCEDURE [dbo].[in_chengji_filter]
	(
		@examer nvarchar(20),
		@examid nvarchar(50),
		@operator char(1),
		@point decimal,
		@newExamId nvarchar(50)
	)
AS
   /*
      返回-3，无权操作。
      返回-2，操作符错误。
      返回-1，不存在该次考试。
      
      返回>=0，操作成功。
   */
	/* SET NOCOUNT ON */
	declare @examid_adm nvarchar(20)
	SELECT @examid_adm=examiner
	FROM exam
	WHERE (id = @newExamId)
	if(@examid_adm is null) return -1
	if (@examid_adm<>@examer) return -3
	declare @newExameeTable table(id nvarchar(20))
	if(@operator='1')
	  begin
	     insert into @newExameeTable(id) SELECT examinee
	                                      FROM chengji
	                                      WHERE (examid = @examid) AND (score < @point)
       
	  end
	else
	  begin
	     if(@operator='2')
	        insert into @newExameeTable(id) SELECT examinee
	                                      FROM chengji
	                                      WHERE (examid = @examid) AND (score <= @point)
	     else
	        begin
	           if(@operator='3')
	             insert into @newExameeTable(id) SELECT examinee
	                                      FROM chengji
	                                      WHERE (examid = @examid) AND (score > @point)
	           else
	             begin
	                if(@operator='4')
	                    insert into @newExameeTable(id) SELECT examinee
	                                      FROM chengji
	                                      WHERE (examid = @examid) AND (score >= @point)
	             else
	               return -2
	             end
	        
	        end
	  end
	  
	  DECLARE individual_cursor CURSOR LOCAL FOR select id from @newExameeTable
	OPEN individual_cursor
    declare @individualId nvarchar(20)
    FETCH NEXT FROM individual_cursor into @individualId
    WHILE @@FETCH_STATUS = 0
      BEGIN
         declare @find bit
         select @find=count(*) from chengji where (examid=@newExamId)and(examinee=@individualId)
         if (@find=0)
           begin
            INSERT INTO chengji
	      (examid,score,examinee)values(@newExamId,0,@individualId)
           
           end
         
         FETCH NEXT FROM individual_cursor into @individualId
      end
	
	RETURN 1
GO
/****** Object:  StoredProcedure [dbo].[we_t4_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t4_delete]
	(
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	if exists(select id from t4 WHERE (id = @id)and(@subjectId=@subjectId))
	begin
	DELETE FROM t4
	WHERE (id = @id)
	exec we_testsKeyWord_delete @testId=@id,@testClass=4
	end
	
	return
GO
/****** Object:  StoredProcedure [dbo].[we_t3_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t3_delete]
	(
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	if exists(select id from t3 WHERE (id = @id)and(@subjectId=@subjectId))
	begin
	DELETE FROM t3
	WHERE (id = @id)
	exec we_testsKeyWord_delete @testId=@id,@testClass=3
	end
	
	return
GO
/****** Object:  StoredProcedure [dbo].[we_t2_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t2_delete]
	(
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	if exists(select id from t2 WHERE (id = @id)and(@subjectId=@subjectId))
	begin
	DELETE FROM t2
	WHERE (id = @id)
	exec we_testsKeyWord_delete @testId=@id,@testClass=2
	end
	
	return
GO
/****** Object:  StoredProcedure [dbo].[we_t1_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t1_delete]
	(
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	if exists(select id from t1 WHERE (id = @id)and(@subjectId=@subjectId))
	begin
	DELETE FROM t1
	WHERE (id = @id)
	exec we_testsKeyWord_delete @testId=@id,@testClass=1
	end
	
	return
GO
/****** Object:  StoredProcedure [dbo].[we_t0_delete]    Script Date: 11/04/2010 16:14:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_t0_delete]
	(
		@id bigint,
		@subjectId bigint
	)
AS
	/* SET NOCOUNT ON */
	if exists(select id from t0 WHERE (id = @id)and(@subjectId=@subjectId))
	begin
	DELETE FROM t0
	WHERE (id = @id)
	exec we_testsKeyWord_delete @testId=@id,@testClass=0
	end
	
	return
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT5_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT5_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
		@eKey char(1),
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey=' ')or(@eKey is null)
	DELETE FROM examinee_key_t5 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	else
	begin
	
	if not exists(select testId from examinee_key_t5 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid))
	INSERT INTO examinee_key_t5
	      (examid, examineeId, testId, eKey, score)
	VALUES (@examid, @examineeId, @testId, @eKey, @score)
	else
	UPDATE examinee_key_t5
	SET examid = @examid, examineeId = @examineeId, testId = @testId, eKey = @eKey, 
	      score = @score where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	      end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT5_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT5_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,ekey,score
	FROM examinee_key_t5
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT5_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT5_AnalysePaper]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT  testId, score, COUNT(score) AS groupCount
FROM      examinee_key_t5 WHERE (examid = @examid)
GROUP BY testId, score
ORDER BY testId, score DESC

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_up_score_checker]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_up_score_checker]

	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
	
		--@groupNo smallint,
		@score decimal(5,2),
		@checker nvarchar(20)
	)

AS
	/* SET NOCOUNT ON */
	
	declare @groupNo smallint--阅卷人所在的小组
	select top 1 @groupNo=groupNo from [group] where examid=@examid and userid=@checker
	if @groupNo=null RETURN
	
	declare @PSN int
	select @PSN=SN from examinee_key_t4 where (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId)
	if @PSN is null
	begin
	declare @SN int
	SELECT top 1  @SN=SN
	FROM examinee_key_t4
	WHERE (examid = @examid) AND(checker = @checker)
	ORDER BY SN DESC
	if @SN is null set @SN=0
	UPDATE examinee_key_t4
	SET score = @score, checker = @checker,SN=@SN+1,checked=1
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId)  AND (groupNo = @groupNo)
	end
	else
	UPDATE examinee_key_t4
	SET score = @score, checker = @checker,checked=1
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId)  AND (groupNo = @groupNo)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
		@eKey text,
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey is null)
	DELETE FROM examinee_key_t4 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	else
	if not exists(select testId from examinee_key_t4 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid))
	INSERT INTO examinee_key_t4
	      (examid, examineeId, testId, score, eKey)
	VALUES (@examid, @examineeId, @testId, @score, @eKey)
	else
	UPDATE examinee_key_t4
	SET examid = @examid, examineeId = @examineeId, testId = @testId,checked=0, 
	      score = @score, eKey = @eKey where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_getCount]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_getCount]
	
	(
	@examid nvarchar(50),
	@groupNo smallint
	)
	
AS
	/* SET NOCOUNT ON */
	
	
	
	
	SELECT testId,COUNT(examineeId)as testCount
	FROM examinee_key_t4 WHERE (examid = @examid) AND (groupNo = @groupno)
	GROUP BY testId

	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,ekey,score
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_checkedRange]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_checkedRange]
	
	(
	 @examid nvarchar(50),
	 @checker nvarchar(20),
	 @minSN int output,
	 @maxSN int output
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT @minSN=min(SN)
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (checker = @checker) and (checked=1)
SELECT @maxSN=max(SN)
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (checker = @checker) and (checked=1)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_checkedCountForTest]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_checkedCountForTest]
	(
		@examid nvarchar(50),
		@testId varchar(10)
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(examineeId)as testCount
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (testId = @testId) AND (checked=1)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_checkDistribution]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_checkDistribution]
	(
		@examid nvarchar(50),
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @groupNo smallint--阅卷人所在的小组
	select top 1 @groupNo=groupNo from [group] where examid=@examid and userid=@checker
	if @groupNo=null RETURN
	
	
	declare @table table(examineeId nvarchar(20),testId varchar(10))
	insert into @table(examineeId,testId)SELECT DISTINCT top 10 examineeId,testId
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (groupNo = @groupNo) and (checked=0) ORDER BY testId
	
	
	declare @testId varchar(10)
	select top 1 @testId=testId from @table
	
	
	declare @addr smallint
	set @addr=1
	SELECT examineeId, testId, @addr, score, checker ,eKey,sn
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (testid = @testId) AND (examineeId in (select examineeId from @table where testid = @testId))
	ORDER BY examineeId
	
    UPDATE examinee_key_t4
	SET checker = @checker
	WHERE (examid = @examid) AND (testid = @testId) AND (examineeId in (select examineeId from @table where testid = @testId))
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT4_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT4_AnalysePaper]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT  testId, score, COUNT(score) AS groupCount
FROM      examinee_key_t4 WHERE (examid = @examid)
GROUP BY testId, score
ORDER BY testId, score DESC

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT3_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT3_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
		@eKey bit,
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey is null)
	DELETE FROM examinee_key_t3 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	else
	begin
	
	
	if not exists(select testId from examinee_key_t3 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid))
	INSERT INTO examinee_key_t3
	      (examid, examineeId, testId, eKey, score)
	VALUES (@examid, @examineeId, @testId, @eKey, @score)
	else
	UPDATE examinee_key_t3
	SET examid = @examid, examineeId = @examineeId, testId = @testId, eKey = @eKey, 
	      score = @score where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	      end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT3_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT3_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,ekey,score
	FROM examinee_key_t3
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT3_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT3_AnalysePaper]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT  testId, score, COUNT(score) AS groupCount
FROM      examinee_key_t3 WHERE (examid = @examid)
GROUP BY testId, score
ORDER BY testId, score DESC

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT2_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
		@insideAddr smallint,
		@eKey nvarchar(1500),
		@score decimal(5,2)	
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey is null)or(@eKey='')or(@eKey=' ')
	DELETE FROM examinee_key_t2 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)and (insideAddr=@insideAddr)
	else
	begin
	
	
	if not exists(select testId from examinee_key_t2 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid) and (insideAddr=@insideAddr))
	INSERT INTO examinee_key_t2
	      (examid, examineeId, testId, eKey, score, insideAddr)
	VALUES (@examid, @examineeId, @testId, @eKey, @score, @insideAddr)
	else
	UPDATE examinee_key_t2
	SET examid = @examid, examineeId = @examineeId, testId = @testId, eKey = @eKey,checked=0, 
	      score = @score where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid) and (insideAddr=@insideAddr)
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_getCount]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT2_getCount]
	
	(
	@examid nvarchar(50),
	@groupNo smallint
	)
	
AS
	/* SET NOCOUNT ON */
	declare @table table(examineeId nvarchar(20),testId varchar(10))
	insert into @table(examineeId,testId)
	SELECT DISTINCT examineeId,testId
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (groupNo = @groupno)
	
	
	
	
	SELECT testId,COUNT(examineeId)as testCount
	FROM @table
	GROUP BY testId

	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT2_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,insideAddr,ekey,score
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_checkedRange]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT2_checkedRange]
	
	(
	 @examid nvarchar(50),
	 @checker nvarchar(20),
	 @minSN int output,
	 @maxSN int output
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT @minSN=min(SN)
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checker = @checker) and (checked=1)
SELECT @maxSN=max(SN)
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (checker = @checker) and (checked=1)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_checkedCountForTest]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT2_checkedCountForTest]
	(
		@examid nvarchar(50),
		@testId varchar(10)
	)
AS
	/* SET NOCOUNT ON */
	
	declare @table table(examineeId nvarchar(20),testId varchar(10))
	insert into @table(examineeId)
	SELECT DISTINCT examineeId
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (testId = @testId) AND (checked=1)
	
	select count(examineeid)as testCount from @table
	

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_checkDistribution]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT2_checkDistribution]
	(
		@examid nvarchar(50),
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @groupNo smallint--阅卷人所在的小组
	select top 1 @groupNo=groupNo from [group] where examid=@examid and userid=@checker
	if @groupNo=null RETURN
	
	declare @table table(examineeId nvarchar(20),testId varchar(10))
	insert into @table(examineeId,testId)SELECT DISTINCT top 10 examineeId,testId
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (groupNo = @groupNo) and (checked=0)
 ORDER BY testId
	
	
	
	declare @testId varchar(10)
	select top 1 @testId=testId from @table
	
	
	
	SELECT examineeId, testId, insideAddr, score, checker ,eKey,sn
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (testid = @testId) AND (examineeId in (select examineeId from @table where testid = @testId))
	ORDER BY examineeId,insideAddr
	
    UPDATE examinee_key_t2
	SET checker = @checker
	WHERE (examid = @examid) AND (testid = @testId) AND (examineeId in (select examineeId from @table where testid = @testId))
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT2_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT2_AnalysePaper]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	declare @temp table([testId]  varchar(10),[score]  [decimal],examineeId nvarchar(20))
INSERT INTO @temp (testId,score,examineeId) select testId,sum(score) as score,examineeId FROM  examinee_key_t2  where examid=@examid GROUP BY examineeId, testId




	SELECT   testId,score, COUNT(score) AS groupCount
FROM      @temp
GROUP BY testId,score
ORDER BY testId, score DESC

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_upgroupNo]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_upgroupNo]
	(
		@examid nvarchar(50),
		@testId bigint,
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	UPDATE examinee_key_t11
	SET groupNo = @groupNo
	WHERE (examid = @examid) AND (testId = @testId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_up_score_checker]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_up_score_checker]

	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId bigint,
	
		--@groupNo smallint,
		@score decimal(5,2),
		@checker nvarchar(20)
	)

AS
	/* SET NOCOUNT ON */
	
	declare @groupNo smallint--阅卷人所在的小组
	select top 1 @groupNo=groupNo from [group] where examid=@examid and userid=@checker
	if @groupNo=null RETURN
	
	declare @PSN int
	select @PSN=SN from examinee_key_t11 where (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId)
	if @PSN is null
	begin
	declare @SN int
	SELECT top 1  @SN=SN
	FROM examinee_key_t11
	WHERE (examid = @examid) AND(checker = @checker)
	ORDER BY SN DESC
	if @SN is null set @SN=0
	UPDATE examinee_key_t11
	SET score = @score, checker = @checker,SN=@SN+1,checked=1
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId)  AND (groupNo = @groupNo)
	end
	else
	UPDATE examinee_key_t11
	SET score = @score, checker = @checker,checked=1
	WHERE (examid = @examid) AND (examineeId = @examineeId) AND (testId = @testId)  AND (groupNo = @groupNo)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId bigint,
		@eKey nvarchar(50),
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey is null)
	DELETE FROM examinee_key_t11 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	else
	if not exists(select testId from examinee_key_t11 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid))
	INSERT INTO examinee_key_t11
	      (examid, examineeId, testId, score, eKey)
	VALUES (@examid, @examineeId, @testId, @score, @eKey)
	else
	UPDATE examinee_key_t11
	SET examid = @examid, examineeId = @examineeId, testId = @testId, 
	      score = @score, eKey = @eKey where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_groupNo]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_groupNo]

	(
		@examid nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	SELECT DISTINCT testId, groupNo
	FROM examinee_key_t11
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,ekey,score
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_count]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_count]
	(
		@examid nvarchar(50),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(testId)
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (groupNo = @groupno)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedRange]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_checkedRange]
	
	(
	 @examid nvarchar(50),
	 @checker nvarchar(20),
	 @minSN int output,
	 @maxSN int output
	)
	
AS
	/* SET NOCOUNT ON */
	SELECT @minSN=min(SN)
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (checker = @checker) and (checked=1)
SELECT @maxSN=max(SN)
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (checker = @checker) and (checked=1)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedPrev]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_checkedPrev]
	(
		@examid nvarchar(50),
		@SN int,
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	
	declare @testId bigint
	SELECT top 1 @testId=testid
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN <@sn) 
	ORDER BY sn desc
	
	declare @addr smallint
	set @addr=1
	SELECT TOP 10 examineeId, testId, @addr, score, checker, eKey,sn
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN < @SN)  AND (testId = @testId)
	ORDER BY SN DESC
	
   
   
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedNext]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_checkedNext]
	(
		@examid nvarchar(50),
		@SN int,
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @testId bigint
	SELECT top 1 @testId=testid
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (checked = 1) AND (checker = @checker) AND (SN >@sn) 
	ORDER BY sn 
	
	declare @addr smallint
	set @addr=1
	SELECT TOP 10 examineeId, testId, @addr, score, checker, eKey,sn
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (checked = 1) AND (testId = @testId) AND (checker = @checker) AND (SN > @SN) AND 
	      (NOT (SN IS NULL))
	ORDER BY SN
	
   
   
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkedCount]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_checkedCount]
	(
		@examid nvarchar(50),
		@groupNo smallint
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(testId)
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (groupNo = @groupno) AND (checked=1)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT11_checkDistribution]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT11_checkDistribution]
	(
		@examid nvarchar(50),
		@checker nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @groupNo smallint--阅卷人所在的小组
	select top 1 @groupNo=groupNo from [group] where examid=@examid and userid=@checker
	if @groupNo=null RETURN
	
	
	declare @table table(examineeId nvarchar(20),testId bigint)
	insert into @table(examineeId,testId)SELECT DISTINCT top 10 examineeId,testId
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (groupNo = @groupNo) and (checked=0) ORDER BY testId
	
	
	declare @testId bigint
	select top 1 @testId=testId from @table
	
	
	declare @addr smallint
	set @addr=1
	SELECT examineeId, testId, @addr, score, checker ,eKey,sn
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (testid = @testId) AND (examineeId in (select examineeId from @table where testid = @testId))
	ORDER BY examineeId
	
    UPDATE examinee_key_t11
	SET checker = @checker
	WHERE (examid = @examid) AND (testid = @testId) AND (examineeId in (select examineeId from @table where testid = @testId))
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT10_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT10_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId bigint,
		@eKey decimal(5,2),
		@score decimal(5,2)
		
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey=0)or(@eKey is null)
	DELETE FROM examinee_key_t10 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	else
	begin
	
	if not exists(select testId from examinee_key_t10 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid))
	INSERT INTO examinee_key_t10
	      (examid, examineeId, testId, eKey, score)
	VALUES (@examid, @examineeId, @testId, @eKey, @score)
	else
	UPDATE examinee_key_t10
	SET examid = @examid, examineeId = @examineeId, testId = @testId, eKey = @eKey, 
	      score = @score where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT10_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT10_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,ekey,score
	FROM examinee_key_t10
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT1_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT1_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
		@eKey varchar(6),
		@score decimal(5,2)
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey='')or(@eKey is null)
	DELETE FROM examinee_key_t1 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	else
	begin
	
	if not exists(select testId from examinee_key_t1 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid))
	INSERT INTO examinee_key_t1
	      (examid, examineeId, testId, eKey, score)
	VALUES (@examid, @examineeId, @testId, @eKey, @score)
	else
	UPDATE examinee_key_t1
	SET examid = @examid, examineeId = @examineeId, testId = @testId, eKey = @eKey, 
	      score = @score where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	      end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT1_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT1_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,ekey,score
	FROM examinee_key_t1
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT1_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT1_AnalysePaper]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT  testId, score, COUNT(score) AS groupCount
FROM      examinee_key_t1 WHERE (examid = @examid)
GROUP BY testId, score
ORDER BY testId, score DESC

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT0_in]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT0_in]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),
		@testId varchar(10),
		@eKey char(1),
		@score decimal(5,2)
		
	)
AS
	/* SET NOCOUNT ON */
	if(@eKey=' ')or(@eKey is null)
	DELETE FROM examinee_key_t0 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	else
	begin
	
	if not exists(select testId from examinee_key_t0 where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid))
	INSERT INTO examinee_key_t0
	      (examid, examineeId, testId, eKey, score)
	VALUES (@examid, @examineeId, @testId, @eKey, @score)
	else
	UPDATE examinee_key_t0
	SET examid = @examid, examineeId = @examineeId, testId = @testId, eKey = @eKey, 
	      score = @score where (examid=@examid) and (examineeid=@examineeid) and (testid=@testid)
	end
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT0_get]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT0_get]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT testId,ekey,score
	FROM examinee_key_t0
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examineeKeyT0_AnalysePaper]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examineeKeyT0_AnalysePaper]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT  testId, score, COUNT(score) AS groupCount
FROM      examinee_key_t0 WHERE (examid = @examid)
GROUP BY testId, score
ORDER BY testId, score DESC

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_register]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examForDepart_register]
	
	(
	@examId nvarchar(50),
	@examinee nvarchar(20),
	 @departId bigint,
	 @parentDepart varchar(500)
	)
	
AS
	/* SET NOCOUNT ON */
	
	declare @c int
		SELECT   @c=count(*)
FROM      examForDepart
WHERE   (exam = @examId)and(((examForDepart.depart = @departId))or((examForDepart.flow=1)and examForDepart.depart in ((select Myvalues FROM My_split(@parentDepart,',')))))


if @c>0
begin
     if not exists(select * from chengji where examid=@examid and examinee=@examinee)
	 begin
	INSERT INTO chengji(examid,examinee)
	values(@examId,@examinee)
	select 1--'添加成功'
	end
	else
select 0--'已经是该场考试的考生'
end
else
begin

select -1--'无权参加'
end

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_myExam]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examForDepart_myExam]
	
	(
	
	 @departId bigint,
	 @parentDepart varchar(500)
	)
	
AS
	/* SET NOCOUNT ON */
	


SELECT   exam.id,exam.examiner, exam.startTime, exam.endTime,exam.timeLen
FROM      exam INNER JOIN
                examForDepart ON exam.id = examForDepart.exam
WHERE   (examForDepart.depart = @departId)or((examForDepart.flow=1)and examForDepart.depart in ((select Myvalues FROM My_split(@parentDepart,','))) )
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_insert]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examForDepart_insert]
	
	(
	@examId nvarchar(50),
	@departId bigint,
	@flow bit
	)
	
AS
	/* SET NOCOUNT ON */
	if not exists(select * from examForDepart where (exam=@examId) and (depart=@departId))
INSERT INTO examForDepart
                (exam, depart, flow)
VALUES   (@examId,@departId,@flow)
else
UPDATE  examForDepart
SET         flow = @flow
WHERE   (exam = @examId) AND (depart = @departId)

	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_getByExam]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examForDepart_getByExam]
	
	(
	@examId nvarchar(50)
	)
	
AS
	/* SET NOCOUNT ON */
	
SELECT   depart, flow
FROM      examForDepart
WHERE   (exam = @examId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_examForDepart_delete]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_examForDepart_delete]
	
	(
	@examId nvarchar(50),
	@departId bigint
	)
	
AS
	/* SET NOCOUNT ON */
	
DELETE FROM examForDepart
WHERE   (exam = @examId) AND (depart = @departId)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_myScoresCount]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_myScoresCount]
	(
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	
	select  COUNT(score) AS Expr1 from chengji INNER JOIN
	      exam ON chengji.examid = exam.id   where (exam.displayScore<>0)and (chengji.times>=1) and(examinee=@examineeId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_ipToExamee]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_ipToExamee]
	(
		@examid nvarchar(50),
		@examinee nvarchar(20),
		@ip1 varchar(30),
		@ip2 varchar(30)
		
	)
AS
	/* SET NOCOUNT ON */
	UPDATE chengji
	SET ip1 = @ip1, ip2 = @ip2, ip = NULL
	WHERE (examid = @examid) AND (examinee = @examinee)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_inExamState]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_inExamState]
	(
		@examinee nvarchar(20),
		@compareTime datetime
	)
AS
	/* SET NOCOUNT ON */
	SELECT count(chengji.score)
	FROM chengji INNER JOIN
	      exam ON chengji.examid = exam.id
	WHERE (chengji.examinee = @examinee) AND (chengji.submit = 0)AND  
	      (start=1) AND (exam.endtime > @compareTime) AND (exam.starttime < @compareTime)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_getNotStaticKeyList]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_getNotStaticKeyList]
	(
		@examid nvarchar(50)
	)
AS
	 SET NOCOUNT ON 
	
	
	SELECT examinee
	FROM chengji 
	WHERE (examid = @examid)and(staticKey=0)
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_getMyScoresPage]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_getMyScoresPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord int,
	
	@examineeId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from chengji INNER JOIN
	      exam ON chengji.examid = exam.id   where (exam.displayScore<>0)and (chengji.times>=1) and(examinee=@examineeId) order by examid desc) a  order by a.examinee) b order by b.examinee desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_getList]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_getList]
	(
		@examid nvarchar(50)
	)
AS
	 SET NOCOUNT ON 
	
	
	SELECT chengji.examinee AS id, chengji.score, [user].userName, 
	      [user].departId AS department
	FROM chengji INNER JOIN
	      [user] ON chengji.examinee = [user].id
	WHERE (chengji.examid = @examid)
	ORDER BY chengji.score DESC
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_getExamineesPage]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_getExamineesPage]
	
	(
	@pageIndex int,
	@pageSize int,
	@totalRecord int,
	
	@examId nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	declare @thisPageSize int
	set @thisPageSize=@pageSize
	if(@pageIndex*@pageSize>@totalRecord)
	set @thisPageSize=@totalRecord % @pageSize
	
	select b.* from (select top (@thisPageSize) a.* from (select top (@pageIndex*@pageSize) * from chengji where (examId=@examId) order by examinee desc) a  order by a.examinee) b order by b.examinee desc
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_getAScore]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_getAScore]
	(
		@examid nvarchar(50),
		@examinee nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	SELECT score, enterTime, ip, ip1, ip2,staticKey,times,usedMinutes
	FROM chengji
	WHERE (examinee = @examinee) AND (examid = @examId)
GO
/****** Object:  StoredProcedure [dbo].[we_score_delExaminee]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_delExaminee]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	SET NOCOUNT ON
	BEGIN TRANSACTION
	DELETE FROM chengji
	WHERE (examid = @examid) AND (examinee = @examineeId)
	DELETE FROM examinee_key_t0
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t1
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t2
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t3
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t4
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	DELETE FROM examinee_key_t5
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	COMMIT
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_count]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_count]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(score) AS Expr1
	FROM chengji
	WHERE (examid = @examid)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_calculateScore]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_calculateScore]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	declare @totalScore0 decimal(5,2)	
	SELECT @totalScore0=SUM(score)
	FROM examinee_key_t0
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	if (@totalScore0 is null) set @totalScore0=0
	
	declare @totalScore1 decimal(5,2)	
	SELECT @totalScore1=SUM(score)
	FROM examinee_key_t1
	WHERE (examid = @examid) AND (examineeId = @examineeId)	
	if (@totalScore1 is null) set @totalScore1=0	
	
	declare @totalScore2 decimal(5,2)		
	SELECT @totalScore2=SUM(score)
	FROM examinee_key_t2
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	if (@totalScore2 is null) set @totalScore2=0
	
	declare @totalScore3 decimal(5,2)		
	SELECT @totalScore3=SUM(score)
	FROM examinee_key_t3
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	if (@totalScore3 is null) set @totalScore3=0
	
	declare @totalScore4 decimal(5,2)	
	SELECT @totalScore4=SUM(score)
	FROM examinee_key_t4
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	if (@totalScore4 is null) set @totalScore4=0
		
	declare @totalScore5 decimal(5,2)	
	SELECT @totalScore5=SUM(score)
	FROM examinee_key_t5
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	if (@totalScore5 is null) set @totalScore5=0	
	
	declare @totalScore10 decimal(5,2)	
	SELECT @totalScore10=SUM(score)
	FROM examinee_key_t10
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	if (@totalScore10 is null) set @totalScore10=0
	
	declare @totalScore11 decimal(5,2)	
	SELECT @totalScore11=SUM(score)
	FROM examinee_key_t11
	WHERE (examid = @examid) AND (examineeId = @examineeId)
	if (@totalScore11 is null) set @totalScore11=0
	
	
	
	
	
	declare @totalScore decimal(5,2)
	set @totalScore=@totalScore0+@totalScore1+@totalScore2+@totalScore3+@totalScore4+@totalScore5+@totalScore10+@totalScore11
	if (@totalScore<0)set @totalScore=0
	UPDATE chengji
	SET score = @totalScore
	WHERE (examid = @examid) AND (examinee = @examineeId)
	
	select @totalScore
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_averageScore]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_averageScore]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT   AVG(score)
	FROM      chengji
	WHERE   (examid = @examid) AND (times >= 1)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_AnalyseResult]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_AnalyseResult]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */

	SELECT score, COUNT(score) AS groupCount 
FROM      chengji WHERE (examid = @examid)
GROUP BY score
ORDER BY score DESC

RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_addExamineeFromMyGroup]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_addExamineeFromMyGroup]
	(
		@examid nvarchar(50),
		

		@groupName nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	DECLARE individual_cursor CURSOR LOCAL FOR select individual from mygroup where (groupName=@groupName)
	OPEN individual_cursor
    declare @individualId nvarchar(20)
    FETCH NEXT FROM individual_cursor into @individualId
    WHILE @@FETCH_STATUS = 0
      BEGIN
         declare @find bit
         select @find=count(*) from chengji where (examid=@examid)and(examinee=@individualId)
         if (@find=0)
           begin
            INSERT INTO chengji
	      (examid,score,times,examinee)values(@examid,0,0,@individualId)
           
           end
         
         FETCH NEXT FROM individual_cursor into @individualId
      end
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_addExamineeByPart]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_addExamineeByPart]
	
	(
	@examId nvarchar(50),
		
		@department bigint
	)
	
AS
	/* SET NOCOUNT ON */
	
	DECLARE individual_cursor CURSOR LOCAL FOR select id from [user] where (departId =@department)
	OPEN individual_cursor
    declare @individualId nvarchar(20)
    FETCH NEXT FROM individual_cursor into @individualId
    WHILE @@FETCH_STATUS = 0
      BEGIN
        if not exists(select * from chengji where examid=@examid and examinee=@individualId)
	INSERT INTO chengji(examid,examinee)
	values(@examId,@individualId)
         
         FETCH NEXT FROM individual_cursor into @individualId
      end
	
	
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_addExaminee]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_addExaminee]
	
	(
	@examId nvarchar(50),
		
		@examinee nvarchar(20)
	)
	
AS
	/* SET NOCOUNT ON */
	if not exists(select * from chengji where examid=@examid and examinee=@examinee)
	INSERT INTO chengji(examid,examinee)
	values(@examId,@examinee)
	
	
	
	
	
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_exam_examineesNewExamList]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_exam_examineesNewExamList]
	(
		@examinee nvarchar(20),
		@compareDate datetime
	)
AS
    SET NOCOUNT ON 
    
    SELECT chengji.examid,ip1,ip2, exam.examiner,exam.displayScore as displayScore, exam.startTime, CASE WHEN (exam.enterLimitation -chengji.times) > 0 THEN (exam.enterLimitation -chengji.times) ELSE 9999 END  as allowEnterTimes,
          exam.endTime, exam.timeLen,chengji.score,chengji.usedMinutes, CASE WHEN (chengji.start = 1) and ( chengji.submit=0) then 1 ELSE 0 END  as locked,exam.useLevelForResult
    FROM chengji INNER JOIN
          exam ON chengji.examid = exam.id
    WHERE (chengji.examinee = @examinee) AND (exam.endTime > @compareDate) AND ((exam.enterLimitation=-1)or(exam.enterLimitation >chengji.times))
    
	/* 
	declare @sjxl varchar(900)
	@dwid bigint
	
	SELECT @sjxl=sj
	FROM dw
	WHERE (id = @dwid)
	exec(	
	'SELECT dh as 代号,kksj as 开考时间,jssj as 结束时间 FROM exam WHERE ((((CONVERT(varchar(8), dwid) in (' + @sjxl + ')) or (dwid = '+@dwid+')) and (jc=1)) or ((dwid = '+@dwid+') and (jc=0))) and (jssj>GETDATE()) order by kksj'
	
	)
	*/
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_updateStaticKey]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_updateStaticKey]
	(
		@examid nvarchar(50),
		@examinee nvarchar(20)
	)
AS
	 SET NOCOUNT ON 
	
	
	UPDATE chengji
	SET staticKey = 1
	WHERE (examid = @examid) AND (examinee =@examinee)
	
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_submitCount]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_submitCount]
	(
		@examid nvarchar(50)
	)
AS
	/* SET NOCOUNT ON */
	SELECT COUNT(score) 
	FROM chengji
	WHERE (examid = @examid) AND (times >= 1)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_submit]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_submit]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20),

		@submitDate datetime
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	UPDATE chengji
	SET times=times+1,usedMinutes=DATEDIFF ( minute, enterTime ,@submitDate),submit=1,start=0
	WHERE (examid = @examid) AND (examinee = @examineeId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_startExam]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_startExam]
	(
		@examid nvarchar(50),
		@examinee nvarchar(20),
		@loginIp varchar(30),
		@loginTime datetime
	)
AS
	/* SET NOCOUNT ON */
	UPDATE chengji
	SET enterTime =@loginTime WHERE (examid = @examid) AND (examinee = @examinee)and(start=0)
	
	UPDATE chengji
	SET ip = @loginIp,submit=0,start=1
	WHERE (examid = @examid) AND (examinee = @examinee)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_resetEnterTimes]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_resetEnterTimes]
	(
		@examid nvarchar(50),
		@examineeId nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	
	
	
	UPDATE chengji
	SET times=0
	WHERE (examid = @examid) AND (examinee = @examineeId)
	
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_reEnter]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_reEnter]
	(
		@examid nvarchar(50),
		@examinee nvarchar(20)
	)
AS
	/* SET NOCOUNT ON */
	UPDATE  chengji
	SET         enterTime = NULL, times = 0, ip = NULL,submit=0,start=0
	WHERE   (examid = @examid) AND (examinee = @examinee)
	RETURN
GO
/****** Object:  StoredProcedure [dbo].[we_score_reCalculate]    Script Date: 11/04/2010 16:14:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[we_score_reCalculate]

	(
		@examId nvarchar(50)
	)

AS
	/* SET NOCOUNT ON */
	DECLARE examinees_cursor CURSOR LOCAL FAST_FORWARD READ_ONLY for
	SELECT examinee
	FROM chengji
	WHERE (examid = @examid)
	OPEN examinees_cursor
    declare @userId nvarchar(20)
    FETCH NEXT FROM examinees_cursor INTO @userId
    WHILE @@FETCH_STATUS = 0
    begin
      EXECUTE we_score_calculateScore @examId,@userId
      FETCH NEXT FROM examinees_cursor INTO @userId
    end
    CLOSE examinees_cursor
    DEALLOCATE examinees_cursor

	RETURN
GO