IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'ftone')
DROP DATABASE [ftone]

create database ftone
go
use ftone
go

/****** Object:  StoredProcedure [dbo].[calcZgscore]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[calcZgscore]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[calcZgscore]
GO
/****** Object:  StoredProcedure [dbo].[calcZgscoreAll]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[calcZgscoreAll]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[calcZgscoreAll]
GO
/****** Object:  StoredProcedure [dbo].[clearAll]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[clearAll]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[clearAll]
GO
/****** Object:  StoredProcedure [dbo].[clearDB]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[clearDB]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[clearDB]
GO
/****** Object:  StoredProcedure [dbo].[writekgscore]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[writekgscore]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[writekgscore]
GO
/****** Object:  Table [dbo].[batchno]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[batchno]') AND type in (N'U'))
DROP TABLE [dbo].[batchno]
GO
/****** Object:  Table [dbo].[ta_classAll]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_classAll]') AND type in (N'U'))
DROP TABLE [dbo].[ta_classAll]
GO
/****** Object:  Table [dbo].[ta_config]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_config]') AND type in (N'U'))
DROP TABLE [dbo].[ta_config]
GO
/****** Object:  Table [dbo].[ta_examinfo]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_examinfo]') AND type in (N'U'))
DROP TABLE [dbo].[ta_examinfo]
GO
/****** Object:  Table [dbo].[ta_grade]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_grade]') AND type in (N'U'))
DROP TABLE [dbo].[ta_grade]
GO
/****** Object:  Table [dbo].[ta_qk]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_qk]') AND type in (N'U'))
DROP TABLE [dbo].[ta_qk]
GO
/****** Object:  Table [dbo].[ta_quality]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_quality]') AND type in (N'U'))
DROP TABLE [dbo].[ta_quality]
GO
/****** Object:  Table [dbo].[ta_scanned]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_scanned]') AND type in (N'U'))
DROP TABLE [dbo].[ta_scanned]
GO
/****** Object:  Table [dbo].[ta_scannedlog]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_scannedlog]') AND type in (N'U'))
DROP TABLE [dbo].[ta_scannedlog]
GO
/****** Object:  Table [dbo].[ta_scannedpages]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_scannedpages]') AND type in (N'U'))
DROP TABLE [dbo].[ta_scannedpages]
GO
/****** Object:  Table [dbo].[ta_selstudent]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_selstudent]') AND type in (N'U'))
DROP TABLE [dbo].[ta_selstudent]
GO
/****** Object:  Table [dbo].[ta_status]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_status]') AND type in (N'U'))
DROP TABLE [dbo].[ta_status]
GO
/****** Object:  Table [dbo].[ta_student]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_student]') AND type in (N'U'))
DROP TABLE [dbo].[ta_student]
GO
/****** Object:  Table [dbo].[ta_studentAll]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_studentAll]') AND type in (N'U'))
DROP TABLE [dbo].[ta_studentAll]
GO
/****** Object:  Table [dbo].[ta_Subimage]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_Subimage]') AND type in (N'U'))
DROP TABLE [dbo].[ta_Subimage]
GO
/****** Object:  Table [dbo].[ta_subject]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_subject]') AND type in (N'U'))
DROP TABLE [dbo].[ta_subject]
GO
/****** Object:  Table [dbo].[ta_subjectAll]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_subjectAll]') AND type in (N'U'))
DROP TABLE [dbo].[ta_subjectAll]
GO
/****** Object:  Table [dbo].[ta_teacher]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_teacher]') AND type in (N'U'))
DROP TABLE [dbo].[ta_teacher]
GO
/****** Object:  Table [dbo].[ta_teacherSubject]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_teacherSubject]') AND type in (N'U'))
DROP TABLE [dbo].[ta_teacherSubject]
GO
/****** Object:  Table [dbo].[ta_ver]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_ver]') AND type in (N'U'))
DROP TABLE [dbo].[ta_ver]
GO
/****** Object:  Table [dbo].[tb_ExamPoint]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ExamPoint]') AND type in (N'U'))
DROP TABLE [dbo].[tb_ExamPoint]
GO
/****** Object:  Table [dbo].[tb_favorite]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_favorite]') AND type in (N'U'))
DROP TABLE [dbo].[tb_favorite]
GO
/****** Object:  Table [dbo].[tb_iteminfo]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_iteminfo]') AND type in (N'U'))
DROP TABLE [dbo].[tb_iteminfo]
GO
/****** Object:  Table [dbo].[TB_itemscorels]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_itemscorels]') AND type in (N'U'))
DROP TABLE [dbo].[TB_itemscorels]
GO
/****** Object:  Table [dbo].[tb_itemseq]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_itemseq]') AND type in (N'U'))
DROP TABLE [dbo].[tb_itemseq]
GO
/****** Object:  Table [dbo].[TB_marks]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_marks]') AND type in (N'U'))
DROP TABLE [dbo].[TB_marks]
GO
/****** Object:  Table [dbo].[tb_OMRitemInfo]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]') AND type in (N'U'))
DROP TABLE [dbo].[tb_OMRitemInfo]
GO
/****** Object:  Table [dbo].[tb_resultitem]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultitem]') AND type in (N'U'))
DROP TABLE [dbo].[tb_resultitem]
GO
/****** Object:  Table [dbo].[tb_resultOMRscore]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultOMRscore]') AND type in (N'U'))
DROP TABLE [dbo].[tb_resultOMRscore]
GO
/****** Object:  Table [dbo].[tb_resultStudent]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultStudent]') AND type in (N'U'))
DROP TABLE [dbo].[tb_resultStudent]
GO
/****** Object:  Table [dbo].[tb_resultsubitem]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultsubitem]') AND type in (N'U'))
DROP TABLE [dbo].[tb_resultsubitem]
GO
/****** Object:  Table [dbo].[tb_resultSubject]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]') AND type in (N'U'))
DROP TABLE [dbo].[tb_resultSubject]
GO
/****** Object:  Table [dbo].[TB_ResultsubSubject]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]') AND type in (N'U'))
DROP TABLE [dbo].[TB_ResultsubSubject]
GO
/****** Object:  Table [dbo].[tb_scorelevel]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_scorelevel]') AND type in (N'U'))
DROP TABLE [dbo].[tb_scorelevel]
GO
/****** Object:  Table [dbo].[tb_scoreseginfo]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_scoreseginfo]') AND type in (N'U'))
DROP TABLE [dbo].[tb_scoreseginfo]
GO
/****** Object:  Table [dbo].[tb_scoreseginfoA]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_scoreseginfoA]') AND type in (N'U'))
DROP TABLE [dbo].[tb_scoreseginfoA]
GO
/****** Object:  Table [dbo].[TB_subItemInfo]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_subItemInfo]') AND type in (N'U'))
DROP TABLE [dbo].[TB_subItemInfo]
GO
/****** Object:  Table [dbo].[tb_subjectLevel]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_subjectLevel]') AND type in (N'U'))
DROP TABLE [dbo].[tb_subjectLevel]
GO
/****** Object:  Table [dbo].[tb_subsubject]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_subsubject]') AND type in (N'U'))
DROP TABLE [dbo].[tb_subsubject]
GO
/****** Object:  Table [dbo].[tc_user]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tc_user]') AND type in (N'U'))
DROP TABLE [dbo].[tc_user]
GO
/****** Object:  Default [DF__batchno__batchno__7E37BEF6]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__batchno__batchno__7E37BEF6]') AND parent_object_id = OBJECT_ID(N'[dbo].[batchno]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__batchno__batchno__7E37BEF6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[batchno] DROP CONSTRAINT [DF__batchno__batchno__7E37BEF6]
END


End
GO
/****** Object:  Default [DF__ta_examin__grade__3D5E1FD2]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_examin__grade__3D5E1FD2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_examin__grade__3D5E1FD2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] DROP CONSTRAINT [DF__ta_examin__grade__3D5E1FD2]
END


End
GO
/****** Object:  Default [DF_ta_examinfo_gradename]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_examinfo_gradename]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_examinfo_gradename]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] DROP CONSTRAINT [DF_ta_examinfo_gradename]
END


End
GO
/****** Object:  Default [DF__ta_examin__pixel__3E52440B]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_examin__pixel__3E52440B]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_examin__pixel__3E52440B]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] DROP CONSTRAINT [DF__ta_examin__pixel__3E52440B]
END


End
GO
/****** Object:  Default [DF__ta_examin__statu__3F466844]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_examin__statu__3F466844]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_examin__statu__3F466844]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] DROP CONSTRAINT [DF__ta_examin__statu__3F466844]
END


End
GO
/****** Object:  Default [DF_ta_examinfo_quality]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_examinfo_quality]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_examinfo_quality]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] DROP CONSTRAINT [DF_ta_examinfo_quality]
END


End
GO
/****** Object:  Default [DF__TA_qk__qk__2180FB33]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TA_qk__qk__2180FB33]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_qk]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TA_qk__qk__2180FB33]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_qk] DROP CONSTRAINT [DF__TA_qk__qk__2180FB33]
END


End
GO
/****** Object:  Default [DF__ta_scanne__roomi__2739D489]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_scanne__roomi__2739D489]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_scanne__roomi__2739D489]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] DROP CONSTRAINT [DF__ta_scanne__roomi__2739D489]
END


End
GO
/****** Object:  Default [DF__ta_scanne__clipe__282DF8C2]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_scanne__clipe__282DF8C2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_scanne__clipe__282DF8C2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] DROP CONSTRAINT [DF__ta_scanne__clipe__282DF8C2]
END


End
GO
/****** Object:  Default [DF_ta_scanned_tasked]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_scanned_tasked]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_scanned_tasked]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] DROP CONSTRAINT [DF_ta_scanned_tasked]
END


End
GO
/****** Object:  Default [DF_ta_scanned_status]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_scanned_status]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_scanned_status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] DROP CONSTRAINT [DF_ta_scanned_status]
END


End
GO
/****** Object:  Default [DF_ta_scanned_errcode]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_scanned_errcode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_scanned_errcode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] DROP CONSTRAINT [DF_ta_scanned_errcode]
END


End
GO
/****** Object:  Default [DF_ta_student_roomid]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_student_roomid]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_student]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_student_roomid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_student] DROP CONSTRAINT [DF_ta_student_roomid]
END


End
GO
/****** Object:  Default [DF_ta_student_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_student_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_student]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_student_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_student] DROP CONSTRAINT [DF_ta_student_isvalid]
END


End
GO
/****** Object:  Default [DF_ta_student_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_student_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_student]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_student_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_student] DROP CONSTRAINT [DF_ta_student_branch]
END


End
GO
/****** Object:  Default [DF_ta_studentAll_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_studentAll_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_studentAll]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_studentAll_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_studentAll] DROP CONSTRAINT [DF_ta_studentAll_branch]
END


End
GO
/****** Object:  Default [DF__ta_Subima__seqed__634EBE90]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_Subima__seqed__634EBE90]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_Subimage]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_Subima__seqed__634EBE90]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_Subimage] DROP CONSTRAINT [DF__ta_Subima__seqed__634EBE90]
END


End
GO
/****** Object:  Default [DF_ta_subject_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF_ta_subject_branch]
END


End
GO
/****** Object:  Default [DF__ta_subjec__paper__6A30C649]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subjec__paper__6A30C649]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subjec__paper__6A30C649]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF__ta_subjec__paper__6A30C649]
END


End
GO
/****** Object:  Default [DF__ta_subjec__isDou__6B24EA82]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subjec__isDou__6B24EA82]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subjec__isDou__6B24EA82]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF__ta_subjec__isDou__6B24EA82]
END


End
GO
/****** Object:  Default [DF__ta_subject__FDir__6C190EBB]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subject__FDir__6C190EBB]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subject__FDir__6C190EBB]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF__ta_subject__FDir__6C190EBB]
END


End
GO
/****** Object:  Default [DF__ta_subject__BDir__6D0D32F4]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subject__BDir__6D0D32F4]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subject__BDir__6D0D32F4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF__ta_subject__BDir__6D0D32F4]
END


End
GO
/****** Object:  Default [DF_ta_subject_subsubject]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_subsubject]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_subsubject]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF_ta_subject_subsubject]
END


End
GO
/****** Object:  Default [DF_ta_subject_state]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_state]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_state]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF_ta_subject_state]
END


End
GO
/****** Object:  Default [DF_ta_subject_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] DROP CONSTRAINT [DF_ta_subject_isvalid]
END


End
GO
/****** Object:  Default [DF_ta_subjectAll_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subjectAll_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subjectAll]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subjectAll_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subjectAll] DROP CONSTRAINT [DF_ta_subjectAll_branch]
END


End
GO
/****** Object:  Default [DF__TB_itemsc__Score__5A1A5A11]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_itemsc__Score__5A1A5A11]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_itemscorels]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_itemsc__Score__5A1A5A11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_itemscorels] DROP CONSTRAINT [DF__TB_itemsc__Score__5A1A5A11]
END


End
GO
/****** Object:  Default [DF__tb_itemse__compl__339FAB6E]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_itemse__compl__339FAB6E]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_itemseq]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_itemse__compl__339FAB6E]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_itemseq] DROP CONSTRAINT [DF__tb_itemse__compl__339FAB6E]
END


End
GO
/****** Object:  Default [DF__TB_marks__x__6EE06CCD]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_marks__x__6EE06CCD]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_marks]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_marks__x__6EE06CCD]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_marks] DROP CONSTRAINT [DF__TB_marks__x__6EE06CCD]
END


End
GO
/****** Object:  Default [DF__TB_marks__y__6FD49106]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_marks__y__6FD49106]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_marks]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_marks__y__6FD49106]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_marks] DROP CONSTRAINT [DF__TB_marks__y__6FD49106]
END


End
GO
/****** Object:  Default [DF__TB_marks__type__70C8B53F]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_marks__type__70C8B53F]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_marks]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_marks__type__70C8B53F]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_marks] DROP CONSTRAINT [DF__TB_marks__type__70C8B53F]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__fulls__787EE5A0]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__fulls__787EE5A0]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__fulls__787EE5A0]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] DROP CONSTRAINT [DF__tb_OMRite__fulls__787EE5A0]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__subsu__797309D9]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__subsu__797309D9]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__subsu__797309D9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] DROP CONSTRAINT [DF__tb_OMRite__subsu__797309D9]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__multi__7A672E12]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__multi__7A672E12]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__multi__7A672E12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] DROP CONSTRAINT [DF__tb_OMRite__multi__7A672E12]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__nansw__5E8A0973]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__nansw__5E8A0973]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__nansw__5E8A0973]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] DROP CONSTRAINT [DF__tb_OMRite__nansw__5E8A0973]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__answe__5F7E2DAC]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__answe__5F7E2DAC]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__answe__5F7E2DAC]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] DROP CONSTRAINT [DF__tb_OMRite__answe__5F7E2DAC]
END


End
GO
/****** Object:  Default [DF_tb_resultitem_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tb_resultitem_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultitem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tb_resultitem_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultitem] DROP CONSTRAINT [DF_tb_resultitem_isvalid]
END


End
GO
/****** Object:  Default [DF__tb_omrsco__score__3B95D2F1]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_omrsco__score__3B95D2F1]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultOMRscore]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_omrsco__score__3B95D2F1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultOMRscore] DROP CONSTRAINT [DF__tb_omrsco__score__3B95D2F1]
END


End
GO
/****** Object:  Default [DF__TB_Result__Score__52793849]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__Score__52793849]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultStudent]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__Score__52793849]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultStudent] DROP CONSTRAINT [DF__TB_Result__Score__52793849]
END


End
GO
/****** Object:  Default [DF_tb_resultsubitem_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tb_resultsubitem_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultsubitem]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tb_resultsubitem_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultsubitem] DROP CONSTRAINT [DF_tb_resultsubitem_isvalid]
END


End
GO
/****** Object:  Default [DF__TB_Result__kgSco__19DFD96B]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__kgSco__19DFD96B]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__kgSco__19DFD96B]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultSubject] DROP CONSTRAINT [DF__TB_Result__kgSco__19DFD96B]
END


End
GO
/****** Object:  Default [DF__TB_Result__zgSco__1AD3FDA4]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__zgSco__1AD3FDA4]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__zgSco__1AD3FDA4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultSubject] DROP CONSTRAINT [DF__TB_Result__zgSco__1AD3FDA4]
END


End
GO
/****** Object:  Default [DF__TB_Result__Score__1BC821DD]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__Score__1BC821DD]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__Score__1BC821DD]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultSubject] DROP CONSTRAINT [DF__TB_Result__Score__1BC821DD]
END


End
GO
/****** Object:  Default [DF__TB_Result__kgSco__4C8B54C9]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__kgSco__4C8B54C9]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__kgSco__4C8B54C9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_ResultsubSubject] DROP CONSTRAINT [DF__TB_Result__kgSco__4C8B54C9]
END


End
GO
/****** Object:  Default [DF__TB_Result__zgSco__4D7F7902]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__zgSco__4D7F7902]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__zgSco__4D7F7902]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_ResultsubSubject] DROP CONSTRAINT [DF__TB_Result__zgSco__4D7F7902]
END


End
GO
/****** Object:  Default [DF__TB_Result__Score__4E739D3B]    Script Date: 12/03/2013 18:39:24 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__Score__4E739D3B]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__Score__4E739D3B]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_ResultsubSubject] DROP CONSTRAINT [DF__TB_Result__Score__4E739D3B]
END


End
GO
/****** Object:  Default [DF__TB_subItemI__kid__70DDC3D8]    Script Date: 12/03/2013 18:39:25 ******/
IF  EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_subItemI__kid__70DDC3D8]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_subItemInfo]'))
Begin
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_subItemI__kid__70DDC3D8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_subItemInfo] DROP CONSTRAINT [DF__TB_subItemI__kid__70DDC3D8]
END


End
GO
/****** Object:  Table [dbo].[tc_user]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tc_user]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tc_user](
	[userid] [int] IDENTITY(1,1) NOT NULL,
	[usercode] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[username] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[passwd] [nvarchar](40) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK__tc_user__5AD97420] PRIMARY KEY CLUSTERED 
(
	[userid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
SET IDENTITY_INSERT [dbo].[tc_user] ON
INSERT [dbo].[tc_user] ([userid], [usercode], [username], [passwd]) VALUES (1, N'admin', N'admin', N'D41D8CD98F00B204E9800998ECF8427E')
SET IDENTITY_INSERT [dbo].[tc_user] OFF
/****** Object:  Table [dbo].[tb_subsubject]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_subsubject]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_subsubject](
	[aid] [int] IDENTITY(1,1) NOT NULL,
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[subsubject] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_tb_subsubject] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[subsubject] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_subjectLevel]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_subjectLevel]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_subjectLevel](
	[subjectid] [int] NOT NULL,
	[levelid] [int] NOT NULL,
	[levelValue] [decimal](6, 0) NOT NULL,
 CONSTRAINT [PK_tb_subjectLevel] PRIMARY KEY CLUSTERED 
(
	[subjectid] ASC,
	[levelid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[TB_subItemInfo]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_subItemInfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_subItemInfo](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[subitemno] [int] NOT NULL,
	[subitemName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[score] [decimal](5, 2) NULL,
	[kid] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_TB_subitemInfo] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[itemno] ASC,
	[subitemno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_scoreseginfoA]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_scoreseginfoA]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_scoreseginfoA](
	[score] [decimal](4, 0) NOT NULL
)
END
GO
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(0 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(1 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(10 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(20 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(30 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(100 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(200 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(250 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfoA] ([score]) VALUES (CAST(300 AS Decimal(4, 0)))
/****** Object:  Table [dbo].[tb_scoreseginfo]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_scoreseginfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_scoreseginfo](
	[score] [decimal](4, 0) NOT NULL
)
END
GO
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(0 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(1 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(10 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(20 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(30 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(40 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(50 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(60 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(70 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(80 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(90 AS Decimal(4, 0)))
INSERT [dbo].[tb_scoreseginfo] ([score]) VALUES (CAST(100 AS Decimal(4, 0)))
/****** Object:  Table [dbo].[tb_scorelevel]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_scorelevel]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_scorelevel](
	[id] [int] NOT NULL,
	[levelName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[rate] [float] NOT NULL,
 CONSTRAINT [PK__tb_scorelevel__5AB9788F] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
INSERT [dbo].[tb_scorelevel] ([id], [levelName], [rate]) VALUES (1, N'优秀', 0.8)
INSERT [dbo].[tb_scorelevel] ([id], [levelName], [rate]) VALUES (2, N'良好', 0.7)
INSERT [dbo].[tb_scorelevel] ([id], [levelName], [rate]) VALUES (3, N'及格', 0.6)
INSERT [dbo].[tb_scorelevel] ([id], [levelName], [rate]) VALUES (4, N'差等', 0.3)
/****** Object:  Table [dbo].[TB_ResultsubSubject]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_ResultsubSubject](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[studentID] [int] NOT NULL,
	[subsubject] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[kgScore] [decimal](6, 2) NULL,
	[zgScore] [decimal](6, 2) NULL,
	[Score] [decimal](6, 2) NULL,
 CONSTRAINT [PK_TB_ResultsubSubject_1] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[studentID] ASC,
	[subsubject] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_resultSubject]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_resultSubject](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[kgScore] [decimal](6, 2) NULL,
	[zgScore] [decimal](6, 2) NULL,
	[Score] [decimal](6, 2) NULL,
 CONSTRAINT [PK_TB_ResultSubject] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_resultsubitem]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultsubitem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_resultsubitem](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[subitemno] [int] NOT NULL,
	[score] [decimal](5, 2) NULL,
	[isvalid] [bit] NOT NULL,
 CONSTRAINT [PK_TB_resultsubitem] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[itemno] ASC,
	[studentid] ASC,
	[subitemno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_resultStudent]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultStudent]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_resultStudent](
	[examid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[Score] [decimal](6, 2) NULL,
 CONSTRAINT [PK_TB_ResultStudent] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_resultOMRscore]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultOMRscore]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_resultOMRscore](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[qno] [int] NOT NULL,
	[answer] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[score] [numeric](5, 2) NOT NULL,
 CONSTRAINT [PK_tb_resultOMRscore] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[studentid] ASC,
	[qno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_resultitem]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_resultitem]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_resultitem](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[score] [decimal](5, 2) NOT NULL,
	[userid] [int] NOT NULL,
	[isvalid] [bit] NOT NULL,
 CONSTRAINT [PK_tb_resultitem] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[itemno] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_OMRitemInfo]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_OMRitemInfo](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[qno] [int] NOT NULL,
	[pageno] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[answer] [nvarchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[fullscore] [decimal](5, 2) NOT NULL,
	[subsubject] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[multisel] [bit] NOT NULL,
	[kid] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[other] [nvarchar](2000) COLLATE Chinese_PRC_CI_AS NULL,
	[nanswer] [int] NOT NULL,
	[answertype] [int] NOT NULL,
	[answervalues] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_tb_OMRitemInfo] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[qno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[TB_marks]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_marks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_marks](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[pid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[userid] [int] NOT NULL,
	[x] [int] NOT NULL,
	[y] [int] NOT NULL,
	[type] [int] NOT NULL,
	[msg] [varchar](2000) COLLATE Chinese_PRC_CI_AS NULL,
	[logtime] [datetime] NULL
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_marks]') AND name = N'IX_TB_marks')
CREATE NONCLUSTERED INDEX [IX_TB_marks] ON [dbo].[TB_marks] 
(
	[examid] ASC,
	[subjectid] ASC,
	[itemno] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
/****** Object:  Table [dbo].[tb_itemseq]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_itemseq]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_itemseq](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[imagepath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[completed] [bit] NULL,
 CONSTRAINT [PK_TB_itemseq] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[itemno] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[TB_itemscorels]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_itemscorels]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_itemscorels](
	[aid] [int] IDENTITY(1,1) NOT NULL,
	[examid] [int] NOT NULL,
	[subjectID] [int] NOT NULL,
	[ItemNo] [int] NOT NULL,
	[pid] [int] NOT NULL,
	[studentID] [int] NULL,
	[Npre] [int] NULL,
	[Score] [decimal](5, 2) NULL,
	[userID] [int] NULL,
	[completeTime] [datetime] NULL,
	[imagepath] [nchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_TB_itemscorels] PRIMARY KEY CLUSTERED 
(
	[aid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_iteminfo]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_iteminfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_iteminfo](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[itemname] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[fullscore] [decimal](5, 2) NOT NULL,
	[subsubject] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[descript] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_tb_iteminfo_1] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[itemno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[tb_favorite]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_favorite]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_favorite](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[userid] [int] NOT NULL,
	[favid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[logtime] [datetime] NULL,
	[imagepath] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL
)
END
GO
/****** Object:  Table [dbo].[tb_ExamPoint]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ExamPoint]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tb_ExamPoint](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[exampoint] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[qno] [int] NOT NULL,
 CONSTRAINT [PK_tb_ExamPoint] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[exampoint] ASC,
	[qno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[ta_ver]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_ver]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_ver](
	[ver] [varchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL
)
END
GO
INSERT [dbo].[ta_ver] ([ver]) VALUES (N'3.3')
/****** Object:  Table [dbo].[ta_teacherSubject]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_teacherSubject]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_teacherSubject](
	[teacherid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[grade] [int] NOT NULL,
 CONSTRAINT [PK_ta_teacherSubject] PRIMARY KEY CLUSTERED 
(
	[teacherid] ASC,
	[subjectid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_teacherSubject]') AND name = N'IX_teacherSubject')
CREATE NONCLUSTERED INDEX [IX_teacherSubject] ON [dbo].[ta_teacherSubject] 
(
	[teacherid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
/****** Object:  Table [dbo].[ta_teacher]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_teacher]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_teacher](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[code] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[name] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK__ta_teacher__08B54D69] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_teacher]') AND name = N'IX_teacher')
CREATE UNIQUE NONCLUSTERED INDEX [IX_teacher] ON [dbo].[ta_teacher] 
(
	[code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
/****** Object:  Table [dbo].[ta_subjectAll]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_subjectAll]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_subjectAll](
	[id] [int] NOT NULL,
	[name] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[aliasName] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[branch] [int] NOT NULL,
 CONSTRAINT [PK__ta_subjectAll__4316F928] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_subjectAll]') AND name = N'IX_subjectAll_name')
CREATE UNIQUE NONCLUSTERED INDEX [IX_subjectAll_name] ON [dbo].[ta_subjectAll] 
(
	[name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (1, N'语文', N'语文', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (2, N'数学', N'数学', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (3, N'英语', N'英语', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (4, N'物理', N'物理', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (5, N'化学', N'化学', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (6, N'生物', N'生物', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (7, N'地理', N'地理', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (8, N'思品', N'思品', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (9, N'历史', N'历史', 0)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (10, N'理数', N'理数', 2)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (11, N'文数', N'文数', 1)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (12, N'文科综合', N'政史地', 1)
INSERT [dbo].[ta_subjectAll] ([id], [name], [aliasName], [branch]) VALUES (13, N'理科综合', N'物理化学生物', 2)
/****** Object:  Table [dbo].[ta_subject]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_subject]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_subject](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[name] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[aliasname] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[branch] [int] NOT NULL,
	[papersize] [int] NOT NULL,
	[isDoubleSide] [bit] NOT NULL,
	[FDir] [tinyint] NOT NULL,
	[BDir] [tinyint] NOT NULL,
	[tplfile] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[tplfile2] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[path] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[subsubject] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[state] [int] NOT NULL,
	[isvalid] [bit] NOT NULL,
 CONSTRAINT [PK_ta_subject] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[ta_Subimage]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_Subimage]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_Subimage](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[itemno] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[imagepath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[seqed] [bit] NULL,
 CONSTRAINT [PK_ta_Subimage] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[itemno] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[ta_studentAll]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_studentAll]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_studentAll](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[gradeid] [int] NOT NULL,
	[studentno] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[zkzh] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[name] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[classid] [int] NOT NULL,
	[siteno] [int] NULL,
	[idcard] [nvarchar](18) COLLATE Chinese_PRC_CI_AS NULL,
	[sex] [nchar](1) COLLATE Chinese_PRC_CI_AS NULL,
	[birthyear] [int] NULL,
	[branch] [int] NOT NULL,
 CONSTRAINT [PK__ta_studentAll__1DE57479] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_studentAll]') AND name = N'IX_ta_studentAll')
CREATE UNIQUE NONCLUSTERED INDEX [IX_ta_studentAll] ON [dbo].[ta_studentAll] 
(
	[gradeid] ASC,
	[zkzh] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_studentAll]') AND name = N'IX_ta_studentAll_1')
CREATE UNIQUE NONCLUSTERED INDEX [IX_ta_studentAll_1] ON [dbo].[ta_studentAll] 
(
	[gradeid] ASC,
	[zkzh] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
/****** Object:  Table [dbo].[ta_student]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_student]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_student](
	[examid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[zkzh] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[classid] [int] NOT NULL,
	[roomid] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[siteno] [int] NULL,
	[studentno] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[sex] [nchar](1) COLLATE Chinese_PRC_CI_AS NULL,
	[isvalid] [bit] NOT NULL,
	[branch] [int] NOT NULL,
 CONSTRAINT [PK_ta_student] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_student]') AND name = N'IX_ta_student')
CREATE UNIQUE NONCLUSTERED INDEX [IX_ta_student] ON [dbo].[ta_student] 
(
	[examid] ASC,
	[zkzh] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_student]') AND name = N'IX_ta_student_1')
CREATE NONCLUSTERED INDEX [IX_ta_student_1] ON [dbo].[ta_student] 
(
	[examid] ASC,
	[roomid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
/****** Object:  Table [dbo].[ta_status]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_status]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_status](
	[id] [int] NOT NULL,
	[description] [nvarchar](16) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK_ta_status] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
INSERT [dbo].[ta_status] ([id], [description]) VALUES (0, N'正常')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (1, N'考号不可识别')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (2, N'重号')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (3, N'批内重号')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (4, N'错号')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (5, N'考场号不一致')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (6, N'页不可识别')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (7, N'缺页')
INSERT [dbo].[ta_status] ([id], [description]) VALUES (8, N'页码重复')
/****** Object:  Table [dbo].[ta_selstudent]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_selstudent]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_selstudent](
	[examid] [int] NOT NULL,
	[selstr] [varchar](max) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK__ta_selstudent__164452B1] PRIMARY KEY CLUSTERED 
(
	[examid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[ta_scannedpages]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_scannedpages]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_scannedpages](
	[examid] [int] NOT NULL,
	[id] [int] NOT NULL,
	[pageno] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[image] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[omr] [nvarchar](1000) COLLATE Chinese_PRC_CI_AS NULL,
	[status] [tinyint] NULL,
	[modified] [bit] NULL,
	[isB] [bit] NULL,
	[selectmarks] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_TA_scannedpages] PRIMARY KEY CLUSTERED 
(
	[id] ASC,
	[pageno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_scannedpages]') AND name = N'IX_ta_scannedpages')
CREATE NONCLUSTERED INDEX [IX_ta_scannedpages] ON [dbo].[ta_scannedpages] 
(
	[examid] ASC,
	[subjectid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
/****** Object:  Table [dbo].[ta_scannedlog]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_scannedlog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_scannedlog](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[userid] [int] NOT NULL,
	[batchno] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[scantime] [datetime] NULL,
 CONSTRAINT [PK_TA_scannedlog_1] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[batchno] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[ta_scanned]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_scanned]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_scanned](
	[examid] [int] NOT NULL,
	[id] [int] IDENTITY(1,1) NOT NULL,
	[subjectid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[zkzh] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[classid] [int] NOT NULL,
	[roomid] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[batchno] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[volumeno] [int] NULL,
	[volumepath] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[rescanned] [int] NOT NULL,
	[modified] [bit] NOT NULL,
	[omred] [bit] NOT NULL,
	[cliped] [bit] NOT NULL,
	[isB] [bit] NULL,
	[isMissing] [bit] NULL,
	[tasked] [bit] NOT NULL,
	[status] [tinyint] NOT NULL,
	[errcode] [tinyint] NOT NULL,
	[files] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK__ta_scanned__2645B050] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ta_scanned]') AND name = N'IX_ta_scanned')
CREATE NONCLUSTERED INDEX [IX_ta_scanned] ON [dbo].[ta_scanned] 
(
	[examid] ASC,
	[subjectid] ASC,
	[zkzh] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'ta_scanned', N'COLUMN',N'errcode'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'异常代码，非0为异常卷' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'ta_scanned', @level2type=N'COLUMN',@level2name=N'errcode'
GO
/****** Object:  Table [dbo].[ta_quality]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_quality]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_quality](
	[quality] [int] NOT NULL,
	[r0] [smallint] NOT NULL,
	[r1] [smallint] NOT NULL,
	[r2] [smallint] NOT NULL,
 CONSTRAINT [PK__ta_quality__7C4F7684] PRIMARY KEY CLUSTERED 
(
	[quality] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
INSERT [dbo].[ta_quality] ([quality], [r0], [r1], [r2]) VALUES (0, 14, 20, 40)
INSERT [dbo].[ta_quality] ([quality], [r0], [r1], [r2]) VALUES (1, 14, 20, 60)
/****** Object:  Table [dbo].[ta_qk]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_qk]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_qk](
	[examid] [int] NOT NULL,
	[subjectid] [int] NOT NULL,
	[studentid] [int] NOT NULL,
	[zkzh] [nvarchar](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[qk] [bit] NOT NULL,
 CONSTRAINT [PK_TA_qk] PRIMARY KEY CLUSTERED 
(
	[examid] ASC,
	[subjectid] ASC,
	[studentid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[ta_grade]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_grade]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_grade](
	[id] [int] NOT NULL,
	[name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
 CONSTRAINT [PK__ta_grade__7F60ED59] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (1, N'一年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (2, N'二年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (3, N'三年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (4, N'四年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (5, N'五年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (6, N'六年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (7, N'七年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (8, N'八年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (9, N'九年级')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (10, N'高一')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (11, N'高二')
INSERT [dbo].[ta_grade] ([id], [name]) VALUES (12, N'高三')
/****** Object:  Table [dbo].[ta_examinfo]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_examinfo]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_examinfo](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[examdesc] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[begindate] [datetime] NOT NULL,
	[enddate] [datetime] NULL,
	[gradeid] [int] NOT NULL,
	[gradename] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[pixeltype] [smallint] NOT NULL,
	[imagetype] [smallint] NOT NULL,
	[subimagetype] [smallint] NOT NULL,
	[exampath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[state] [int] NOT NULL,
	[quality] [smallint] NOT NULL,
	[reporttpl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK__ta_examinfo__3C69FB99] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[ta_config]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_config]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_config](
	[reporttpl] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL,
	[backuppath] [nvarchar](255) COLLATE Chinese_PRC_CI_AS NULL
)
END
GO
/****** Object:  Table [dbo].[ta_classAll]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ta_classAll]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ta_classAll](
	[id] [int] NOT NULL,
	[name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[gradeid] [int] NOT NULL,
 CONSTRAINT [PK__ta_classAll__182C9B23] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON)
)
END
GO
/****** Object:  Table [dbo].[batchno]    Script Date: 12/03/2013 18:39:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[batchno]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[batchno](
	[subjectid] [int] NOT NULL,
	[batchno] [int] NULL
)
END
GO
/****** Object:  StoredProcedure [dbo].[writekgscore]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[writekgscore]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
create PROCEDURE [dbo].[writekgscore] 
	@examid int,
	@subjectid int,
	@studentid int,
	@kgscore int
AS
BEGIN
	SET NOCOUNT ON;

-- 写tb_resultSubject
	update tb_resultSubject set kgscore=@kgscore, score=zgscore+@kgscore where examid=@examid and subjectid=@subjectid and studentid=@studentid
	if @@rowcount=0
		insert into tb_resultSubject (examid,subjectid,studentid,kgscore,zgscore,score) values (@examid,@subjectid,@studentid,@kgscore,0,@kgscore)
END
' 
END
GO
/****** Object:  StoredProcedure [dbo].[clearDB]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[clearDB]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[clearDB]
	@examid int
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
declare @begindate datetime, @enddate datetime, @now datetime

	select @begindate=begindate,@enddate=dateadd(day,1,enddate) from ta_examinfo where id=@examid
	--if @@ROWCOUNT=0
	--	return 0
	--set @now=getdate()
	--if (@now>=@begindate and @now<=@enddate)
	--	return 0
	delete from ta_examinfo where id=@examid
	delete from ta_subject where examid=@examid
	delete from tb_subsubject where examid=@examid

    delete from ta_student where examid=@examid
	delete from ta_selstudent where examid=@examid
	delete from ta_qk where examid=@examid
	
	delete from tb_iteminfo where examid=@examid
	delete from tb_subiteminfo where examid=@examid
	delete from tb_OMRiteminfo where examid=@examid

	delete from ta_scannedpages where examid=@examid
	delete from ta_scanned where examid=@examid
	delete from ta_scannedlog where examid=@examid

	delete from ta_subimage where examid=@examid

	delete from tb_itemscorels where examid=@examid
	delete from tb_itemseq where examid=@examid
	delete from tb_favorite where examid=@examid
	delete from tb_marks where examid=@examid
	delete from tb_resultomrscore where examid=@examid
	delete from tb_resultItem where examid=@examid
	delete from tb_resultstudent where examid=@examid
	delete from tb_resultsubItem where examid=@examid
	delete from tb_resultSubject where examid=@examid
	delete from tb_resultsubSubject where examid=@examid

	delete from tb_ExamPoint where examid=@examid
	
	return 1
END


















' 
END
GO
/****** Object:  StoredProcedure [dbo].[clearAll]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[clearAll]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[clearAll] 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	delete from ta_examinfo
	delete from ta_subject
	delete from tb_subsubject

    delete from ta_student
	delete from ta_selstudent
	delete from ta_qk
	
	delete from tb_iteminfo
	delete from tb_subiteminfo
	delete from tb_OMRiteminfo

	delete from ta_scannedpages
	delete from ta_scanned
	delete from ta_scannedlog

	delete from ta_subimage
	delete from tb_itemscorels
	delete from tb_itemseq
	delete from tb_favorite
	delete from tb_marks
	delete from tb_resultomrscore
	delete from tb_resultItem
	delete from tb_resultstudent
	delete from tb_resultsubItem
	delete from tb_resultSubject
	delete from tb_resultsubSubject
	delete from tb_ExamPoint
	
	delete from batchno
	delete from ta_classAll
	delete from ta_studentAll
	delete from ta_teacher
	delete from ta_teacherSubject
	delete from tb_subjectLevel
	
	return 1

END
' 
END
GO
/****** Object:  StoredProcedure [dbo].[calcZgscoreAll]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[calcZgscoreAll]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		pclion
-- Last modified date: 2013-7-16
-- Description:	主观分统分(全部科目)
-- =============================================
CREATE PROCEDURE [dbo].[calcZgscoreAll] 
	@examid int
AS
BEGIN

-- 写tb_resultSubject
DECLARE mycursor CURSOR FAST_FORWARD FOR
	select subjectid,studentid,sum(score) as zgscore from tb_resultitem where examid=@examid and isvalid=1 group by subjectid,studentid
declare @subjectid int, @studentid int, @zgscore decimal(6,2)

open mycursor
fetch next from mycursor into @subjectid, @studentid, @zgscore
WHILE @@FETCH_STATUS = 0
begin
	update tb_resultsubject set zgscore=@zgscore,score=kgscore+@zgscore where examid=@examid and subjectid=@subjectid and studentid=@studentid
	if @@rowcount=0
		insert into tb_resultsubject (examid,subjectid,studentid,kgscore,zgscore,score) values (@examid,@subjectid,@studentid,0,@zgscore,@zgscore)
	fetch next from mycursor into @subjectid, @studentid, @zgscore
end

CLOSE mycursor
DEALLOCATE mycursor

-- 写tb_resultStudent
delete from tb_resultStudent where examid=@examid

DECLARE mycursor CURSOR FAST_FORWARD FOR
	select studentid,sum(score) as score from tb_resultSubject where examid=@examid group by studentid
declare @score decimal(6,2)

open mycursor
fetch next from mycursor into @studentid, @score
WHILE @@FETCH_STATUS = 0
begin
	update tb_resultStudent set score=@score where examid=@examid and studentid=@studentid
	if @@rowcount=0
		insert into tb_resultStudent (examid,studentid,score) values (@examid,@studentid,@score)
	fetch next from mycursor into @studentid, @score
end

CLOSE mycursor
DEALLOCATE mycursor

-- 写tb_resultsubSubject
DECLARE mycursor CURSOR FAST_FORWARD FOR
	select a.subjectid,a.studentid,b.subsubject,sum(a.score) as zgscore from tb_resultitem a 
	left join tb_iteminfo b on a.examid=b.examid and a.subjectid=b.subjectid and a.itemno=b.itemno
	where a.examid=@examid and a.isvalid=1 group by a.subjectid,a.studentid,subsubject
declare @subsubject nvarchar(20)

open mycursor
fetch next from mycursor into @subjectid,@studentid, @subsubject, @zgscore
WHILE @@FETCH_STATUS = 0
begin
	update tb_resultsubSubject set zgscore=@zgscore,score=kgscore+@zgscore where examid=@examid and subjectid=@subjectid and studentid=@studentid and subsubject=@subsubject
	if @@rowcount=0
		insert into tb_resultsubSubject (examid,subjectid,studentid,subsubject,kgscore,zgscore,score) values (@examid,@subjectid,@studentid,@subsubject,0,@zgscore,@zgscore)
	fetch next from mycursor into @subjectid,@studentid, @subsubject, @zgscore
end


CLOSE mycursor
DEALLOCATE mycursor

END
' 
END
GO
/****** Object:  StoredProcedure [dbo].[calcZgscore]    Script Date: 12/03/2013 18:39:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[calcZgscore]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
-- =============================================
-- Author:		pclion
-- Last modified date: 2012-12-04
-- Description:	科目主观分统分
-- =============================================
CREATE PROCEDURE [dbo].[calcZgscore] 
	@examid int,@subjectid int
AS
BEGIN

-- 写tb_resultSubject
DECLARE mycursor CURSOR FAST_FORWARD FOR
	select studentid,sum(score) as zgscore from tb_resultitem where examid=@examid and subjectid=@subjectid and isvalid=1 group by studentid
declare @studentid int, @zgscore decimal(6,2)

open mycursor
fetch next from mycursor into @studentid, @zgscore
WHILE @@FETCH_STATUS = 0
begin
	update tb_resultsubject set zgscore=@zgscore,score=kgscore+@zgscore where examid=@examid and subjectid=@subjectid and studentid=@studentid
	if @@rowcount=0
		insert into tb_resultsubject (examid,subjectid,studentid,kgscore,zgscore,score) values (@examid,@subjectid,@studentid,0,@zgscore,@zgscore)
	fetch next from mycursor into @studentid, @zgscore
end

CLOSE mycursor
DEALLOCATE mycursor

-- 写tb_resultsubSubject
DECLARE mycursor CURSOR FAST_FORWARD FOR
	select a.studentid,b.subsubject,sum(a.score) as zgscore from tb_resultitem a 
	left join tb_iteminfo b on a.examid=b.examid and a.subjectid=b.subjectid and a.itemno=b.itemno
	where a.examid=@examid and a.subjectid=@subjectid and a.isvalid=1 group by a.studentid,subsubject
declare @subsubject nvarchar(20)

open mycursor
fetch next from mycursor into @studentid, @subsubject, @zgscore
WHILE @@FETCH_STATUS = 0
begin
	update tb_resultsubSubject set zgscore=@zgscore,score=kgscore+@zgscore where examid=@examid and subjectid=@subjectid and studentid=@studentid and subsubject=@subsubject
	if @@rowcount=0
		insert into tb_resultsubSubject (examid,subjectid,studentid,subsubject,kgscore,zgscore,score) values (@examid,@subjectid,@studentid,@subsubject,0,@zgscore,@zgscore)
	fetch next from mycursor into @studentid, @subsubject, @zgscore
end


CLOSE mycursor
DEALLOCATE mycursor

END
' 
END
GO
/****** Object:  Default [DF__batchno__batchno__7E37BEF6]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__batchno__batchno__7E37BEF6]') AND parent_object_id = OBJECT_ID(N'[dbo].[batchno]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__batchno__batchno__7E37BEF6]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[batchno] ADD  CONSTRAINT [DF__batchno__batchno__7E37BEF6]  DEFAULT ((0)) FOR [batchno]
END


End
GO
/****** Object:  Default [DF__ta_examin__grade__3D5E1FD2]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_examin__grade__3D5E1FD2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_examin__grade__3D5E1FD2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] ADD  CONSTRAINT [DF__ta_examin__grade__3D5E1FD2]  DEFAULT ((0)) FOR [gradeid]
END


End
GO
/****** Object:  Default [DF_ta_examinfo_gradename]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_examinfo_gradename]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_examinfo_gradename]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] ADD  CONSTRAINT [DF_ta_examinfo_gradename]  DEFAULT ('') FOR [gradename]
END


End
GO
/****** Object:  Default [DF__ta_examin__pixel__3E52440B]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_examin__pixel__3E52440B]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_examin__pixel__3E52440B]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] ADD  CONSTRAINT [DF__ta_examin__pixel__3E52440B]  DEFAULT ((1)) FOR [pixeltype]
END


End
GO
/****** Object:  Default [DF__ta_examin__statu__3F466844]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_examin__statu__3F466844]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_examin__statu__3F466844]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] ADD  CONSTRAINT [DF__ta_examin__statu__3F466844]  DEFAULT ((0)) FOR [state]
END


End
GO
/****** Object:  Default [DF_ta_examinfo_quality]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_examinfo_quality]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_examinfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_examinfo_quality]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_examinfo] ADD  CONSTRAINT [DF_ta_examinfo_quality]  DEFAULT ((0)) FOR [quality]
END


End
GO
/****** Object:  Default [DF__TA_qk__qk__2180FB33]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TA_qk__qk__2180FB33]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_qk]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TA_qk__qk__2180FB33]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_qk] ADD  CONSTRAINT [DF__TA_qk__qk__2180FB33]  DEFAULT ((0)) FOR [qk]
END


End
GO
/****** Object:  Default [DF__ta_scanne__roomi__2739D489]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_scanne__roomi__2739D489]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_scanne__roomi__2739D489]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] ADD  CONSTRAINT [DF__ta_scanne__roomi__2739D489]  DEFAULT ('') FOR [roomid]
END


End
GO
/****** Object:  Default [DF__ta_scanne__clipe__282DF8C2]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_scanne__clipe__282DF8C2]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_scanne__clipe__282DF8C2]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] ADD  CONSTRAINT [DF__ta_scanne__clipe__282DF8C2]  DEFAULT ((0)) FOR [cliped]
END


End
GO
/****** Object:  Default [DF_ta_scanned_tasked]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_scanned_tasked]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_scanned_tasked]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] ADD  CONSTRAINT [DF_ta_scanned_tasked]  DEFAULT ((0)) FOR [tasked]
END


End
GO
/****** Object:  Default [DF_ta_scanned_status]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_scanned_status]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_scanned_status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] ADD  CONSTRAINT [DF_ta_scanned_status]  DEFAULT ((0)) FOR [status]
END


End
GO
/****** Object:  Default [DF_ta_scanned_errcode]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_scanned_errcode]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_scanned]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_scanned_errcode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_scanned] ADD  CONSTRAINT [DF_ta_scanned_errcode]  DEFAULT ((0)) FOR [errcode]
END


End
GO
/****** Object:  Default [DF_ta_student_roomid]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_student_roomid]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_student]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_student_roomid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_student] ADD  CONSTRAINT [DF_ta_student_roomid]  DEFAULT ('') FOR [roomid]
END


End
GO
/****** Object:  Default [DF_ta_student_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_student_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_student]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_student_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_student] ADD  CONSTRAINT [DF_ta_student_isvalid]  DEFAULT ((1)) FOR [isvalid]
END


End
GO
/****** Object:  Default [DF_ta_student_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_student_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_student]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_student_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_student] ADD  CONSTRAINT [DF_ta_student_branch]  DEFAULT ((0)) FOR [branch]
END


End
GO
/****** Object:  Default [DF_ta_studentAll_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_studentAll_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_studentAll]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_studentAll_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_studentAll] ADD  CONSTRAINT [DF_ta_studentAll_branch]  DEFAULT ((0)) FOR [branch]
END


End
GO
/****** Object:  Default [DF__ta_Subima__seqed__634EBE90]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_Subima__seqed__634EBE90]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_Subimage]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_Subima__seqed__634EBE90]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_Subimage] ADD  CONSTRAINT [DF__ta_Subima__seqed__634EBE90]  DEFAULT ((0)) FOR [seqed]
END


End
GO
/****** Object:  Default [DF_ta_subject_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF_ta_subject_branch]  DEFAULT ((0)) FOR [branch]
END


End
GO
/****** Object:  Default [DF__ta_subjec__paper__6A30C649]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subjec__paper__6A30C649]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subjec__paper__6A30C649]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF__ta_subjec__paper__6A30C649]  DEFAULT ((1)) FOR [papersize]
END


End
GO
/****** Object:  Default [DF__ta_subjec__isDou__6B24EA82]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subjec__isDou__6B24EA82]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subjec__isDou__6B24EA82]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF__ta_subjec__isDou__6B24EA82]  DEFAULT ((1)) FOR [isDoubleSide]
END


End
GO
/****** Object:  Default [DF__ta_subject__FDir__6C190EBB]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subject__FDir__6C190EBB]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subject__FDir__6C190EBB]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF__ta_subject__FDir__6C190EBB]  DEFAULT ((0)) FOR [FDir]
END


End
GO
/****** Object:  Default [DF__ta_subject__BDir__6D0D32F4]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__ta_subject__BDir__6D0D32F4]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ta_subject__BDir__6D0D32F4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF__ta_subject__BDir__6D0D32F4]  DEFAULT ((0)) FOR [BDir]
END


End
GO
/****** Object:  Default [DF_ta_subject_subsubject]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_subsubject]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_subsubject]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF_ta_subject_subsubject]  DEFAULT ('') FOR [subsubject]
END


End
GO
/****** Object:  Default [DF_ta_subject_state]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_state]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_state]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF_ta_subject_state]  DEFAULT ((0)) FOR [state]
END


End
GO
/****** Object:  Default [DF_ta_subject_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subject_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subject_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subject] ADD  CONSTRAINT [DF_ta_subject_isvalid]  DEFAULT ((1)) FOR [isvalid]
END


End
GO
/****** Object:  Default [DF_ta_subjectAll_branch]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_ta_subjectAll_branch]') AND parent_object_id = OBJECT_ID(N'[dbo].[ta_subjectAll]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ta_subjectAll_branch]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ta_subjectAll] ADD  CONSTRAINT [DF_ta_subjectAll_branch]  DEFAULT ((0)) FOR [branch]
END


End
GO
/****** Object:  Default [DF__TB_itemsc__Score__5A1A5A11]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_itemsc__Score__5A1A5A11]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_itemscorels]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_itemsc__Score__5A1A5A11]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_itemscorels] ADD  CONSTRAINT [DF__TB_itemsc__Score__5A1A5A11]  DEFAULT ((0)) FOR [Score]
END


End
GO
/****** Object:  Default [DF__tb_itemse__compl__339FAB6E]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_itemse__compl__339FAB6E]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_itemseq]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_itemse__compl__339FAB6E]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_itemseq] ADD  CONSTRAINT [DF__tb_itemse__compl__339FAB6E]  DEFAULT ((0)) FOR [completed]
END


End
GO
/****** Object:  Default [DF__TB_marks__x__6EE06CCD]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_marks__x__6EE06CCD]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_marks]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_marks__x__6EE06CCD]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_marks] ADD  CONSTRAINT [DF__TB_marks__x__6EE06CCD]  DEFAULT ((0)) FOR [x]
END


End
GO
/****** Object:  Default [DF__TB_marks__y__6FD49106]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_marks__y__6FD49106]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_marks]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_marks__y__6FD49106]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_marks] ADD  CONSTRAINT [DF__TB_marks__y__6FD49106]  DEFAULT ((0)) FOR [y]
END


End
GO
/****** Object:  Default [DF__TB_marks__type__70C8B53F]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_marks__type__70C8B53F]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_marks]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_marks__type__70C8B53F]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_marks] ADD  CONSTRAINT [DF__TB_marks__type__70C8B53F]  DEFAULT ((0)) FOR [type]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__fulls__787EE5A0]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__fulls__787EE5A0]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__fulls__787EE5A0]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] ADD  CONSTRAINT [DF__tb_OMRite__fulls__787EE5A0]  DEFAULT ((0)) FOR [fullscore]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__subsu__797309D9]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__subsu__797309D9]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__subsu__797309D9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] ADD  CONSTRAINT [DF__tb_OMRite__subsu__797309D9]  DEFAULT ('') FOR [subsubject]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__multi__7A672E12]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__multi__7A672E12]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__multi__7A672E12]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] ADD  CONSTRAINT [DF__tb_OMRite__multi__7A672E12]  DEFAULT ((0)) FOR [multisel]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__nansw__5E8A0973]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__nansw__5E8A0973]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__nansw__5E8A0973]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] ADD  CONSTRAINT [DF__tb_OMRite__nansw__5E8A0973]  DEFAULT ((4)) FOR [nanswer]
END


End
GO
/****** Object:  Default [DF__tb_OMRite__answe__5F7E2DAC]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_OMRite__answe__5F7E2DAC]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_OMRitemInfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_OMRite__answe__5F7E2DAC]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_OMRitemInfo] ADD  CONSTRAINT [DF__tb_OMRite__answe__5F7E2DAC]  DEFAULT ((2)) FOR [answertype]
END


End
GO
/****** Object:  Default [DF_tb_resultitem_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tb_resultitem_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultitem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tb_resultitem_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultitem] ADD  CONSTRAINT [DF_tb_resultitem_isvalid]  DEFAULT ((1)) FOR [isvalid]
END


End
GO
/****** Object:  Default [DF__tb_omrsco__score__3B95D2F1]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__tb_omrsco__score__3B95D2F1]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultOMRscore]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__tb_omrsco__score__3B95D2F1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultOMRscore] ADD  CONSTRAINT [DF__tb_omrsco__score__3B95D2F1]  DEFAULT ((0)) FOR [score]
END


End
GO
/****** Object:  Default [DF__TB_Result__Score__52793849]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__Score__52793849]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultStudent]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__Score__52793849]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultStudent] ADD  CONSTRAINT [DF__TB_Result__Score__52793849]  DEFAULT ((0)) FOR [Score]
END


End
GO
/****** Object:  Default [DF_tb_resultsubitem_isvalid]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF_tb_resultsubitem_isvalid]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultsubitem]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_tb_resultsubitem_isvalid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultsubitem] ADD  CONSTRAINT [DF_tb_resultsubitem_isvalid]  DEFAULT ((1)) FOR [isvalid]
END


End
GO
/****** Object:  Default [DF__TB_Result__kgSco__19DFD96B]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__kgSco__19DFD96B]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__kgSco__19DFD96B]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultSubject] ADD  CONSTRAINT [DF__TB_Result__kgSco__19DFD96B]  DEFAULT ((0)) FOR [kgScore]
END


End
GO
/****** Object:  Default [DF__TB_Result__zgSco__1AD3FDA4]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__zgSco__1AD3FDA4]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__zgSco__1AD3FDA4]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultSubject] ADD  CONSTRAINT [DF__TB_Result__zgSco__1AD3FDA4]  DEFAULT ((0)) FOR [zgScore]
END


End
GO
/****** Object:  Default [DF__TB_Result__Score__1BC821DD]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__Score__1BC821DD]') AND parent_object_id = OBJECT_ID(N'[dbo].[tb_resultSubject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__Score__1BC821DD]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[tb_resultSubject] ADD  CONSTRAINT [DF__TB_Result__Score__1BC821DD]  DEFAULT ((0)) FOR [Score]
END


End
GO
/****** Object:  Default [DF__TB_Result__kgSco__4C8B54C9]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__kgSco__4C8B54C9]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__kgSco__4C8B54C9]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_ResultsubSubject] ADD  CONSTRAINT [DF__TB_Result__kgSco__4C8B54C9]  DEFAULT ((0)) FOR [kgScore]
END


End
GO
/****** Object:  Default [DF__TB_Result__zgSco__4D7F7902]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__zgSco__4D7F7902]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__zgSco__4D7F7902]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_ResultsubSubject] ADD  CONSTRAINT [DF__TB_Result__zgSco__4D7F7902]  DEFAULT ((0)) FOR [zgScore]
END


End
GO
/****** Object:  Default [DF__TB_Result__Score__4E739D3B]    Script Date: 12/03/2013 18:39:24 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_Result__Score__4E739D3B]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_ResultsubSubject]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_Result__Score__4E739D3B]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_ResultsubSubject] ADD  CONSTRAINT [DF__TB_Result__Score__4E739D3B]  DEFAULT ((0)) FOR [Score]
END


End
GO
/****** Object:  Default [DF__TB_subItemI__kid__70DDC3D8]    Script Date: 12/03/2013 18:39:25 ******/
IF Not EXISTS (SELECT * FROM sys.default_constraints WHERE object_id = OBJECT_ID(N'[dbo].[DF__TB_subItemI__kid__70DDC3D8]') AND parent_object_id = OBJECT_ID(N'[dbo].[TB_subItemInfo]'))
Begin
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__TB_subItemI__kid__70DDC3D8]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[TB_subItemInfo] ADD  CONSTRAINT [DF__TB_subItemI__kid__70DDC3D8]  DEFAULT ('') FOR [kid]
END


End
GO
