USE [SmartHotel]
GO
/****** Object:  Table [dbo].[FloorDefinition]    Script Date: 04/25/2012 11:37:27 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FloorDefinition_fGUID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FloorDefinition] DROP CONSTRAINT [DF_FloorDefinition_fGUID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FloorDefinition_fFloorNo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FloorDefinition] DROP CONSTRAINT [DF_FloorDefinition_fFloorNo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FloorDefinition_fDescription]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FloorDefinition] DROP CONSTRAINT [DF_FloorDefinition_fDescription]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[FloorDefinition]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[FloorDefinition]
GO
/****** Object:  Table [dbo].[DeviceType]    Script Date: 04/25/2012 11:37:29 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DeviceType_fDeviceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DeviceType] DROP CONSTRAINT [DF_DeviceType_fDeviceType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DeviceType_fDeviceName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DeviceType] DROP CONSTRAINT [DF_DeviceType_fDeviceName]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DeviceType_fModel]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DeviceType] DROP CONSTRAINT [DF_DeviceType_fModel]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DeviceType_fDescriptionEng]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DeviceType] DROP CONSTRAINT [DF_DeviceType_fDescriptionEng]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeviceType]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[DeviceType]
GO
/****** Object:  Table [dbo].[OnlineDevice]    Script Date: 04/25/2012 11:37:29 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_OnlineDevice_fDeviceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[OnlineDevice] DROP CONSTRAINT [DF_OnlineDevice_fDeviceType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_OnlineDevice_fSubnetID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[OnlineDevice] DROP CONSTRAINT [DF_OnlineDevice_fSubnetID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_OnlineDevice_fDeviceID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[OnlineDevice] DROP CONSTRAINT [DF_OnlineDevice_fDeviceID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_OnlineDevice_fMAC]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[OnlineDevice] DROP CONSTRAINT [DF_OnlineDevice_fMAC]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_OnlineDevice_fRemark]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[OnlineDevice] DROP CONSTRAINT [DF_OnlineDevice_fRemark]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[OnlineDevice]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[OnlineDevice]
GO
/****** Object:  Table [dbo].[HotelPwd]    Script Date: 04/25/2012 11:37:29 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_HotelPwd_fOldPwd]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[HotelPwd] DROP CONSTRAINT [DF_HotelPwd_fOldPwd]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_HotelPwd_fNewPwd]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[HotelPwd] DROP CONSTRAINT [DF_HotelPwd_fNewPwd]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_HotelPwd_fModifyBy]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[HotelPwd] DROP CONSTRAINT [DF_HotelPwd_fModifyBy]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_HotelPwd_fModifyDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[HotelPwd] DROP CONSTRAINT [DF_HotelPwd_fModifyDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[HotelPwd]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[HotelPwd]
GO
/****** Object:  Table [dbo].[CardInfo]    Script Date: 04/25/2012 11:37:28 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_CardInfo_fCardNumber]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[CardInfo] DROP CONSTRAINT [DF_CardInfo_fCardNumber]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_CardInfo_fNewPwd]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[CardInfo] DROP CONSTRAINT [DF_CardInfo_fNewPwd]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_CardInfo_fRegisterBy]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[CardInfo] DROP CONSTRAINT [DF_CardInfo_fRegisterBy]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_CardInfo_fRegisterDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[CardInfo] DROP CONSTRAINT [DF_CardInfo_fRegisterDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_CardInfo_fModifyBy]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[CardInfo] DROP CONSTRAINT [DF_CardInfo_fModifyBy]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_CardInfo_fModifyDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[CardInfo] DROP CONSTRAINT [DF_CardInfo_fModifyDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[CardInfo]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[CardInfo]
GO
/****** Object:  Table [dbo].[COM]    Script Date: 04/25/2012 11:37:28 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_COM_fCOMName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[COM] DROP CONSTRAINT [DF_COM_fCOMName]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_COM_fBaud]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[COM] DROP CONSTRAINT [DF_COM_fBaud]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[COM]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[COM]
GO
/****** Object:  Table [dbo].[Floor]    Script Date: 04/25/2012 11:37:28 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Floor_fGUID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Floor] DROP CONSTRAINT [DF_Floor_fGUID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Floor_fBuildingNo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Floor] DROP CONSTRAINT [DF_Floor_fBuildingNo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Floor_fFloorNo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Floor] DROP CONSTRAINT [DF_Floor_fFloorNo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Floor_ffDescription]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Floor] DROP CONSTRAINT [DF_Floor_ffDescription]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Floor]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[Floor]
GO
/****** Object:  Table [dbo].[Room]    Script Date: 04/25/2012 11:37:27 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Room_fGUID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Room] DROP CONSTRAINT [DF_Room_fGUID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Room_fBuildingNo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Room] DROP CONSTRAINT [DF_Room_fBuildingNo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Room_fFloorNo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Room] DROP CONSTRAINT [DF_Room_fFloorNo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Room_fRoomNo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Room] DROP CONSTRAINT [DF_Room_fRoomNo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Room_fDescription]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Room] DROP CONSTRAINT [DF_Room_fDescription]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Room]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[Room]
GO
/****** Object:  Table [dbo].[Users]    Script Date: 04/25/2012 11:37:27 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_t_Users_fUserID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Users] DROP CONSTRAINT [DF_t_Users_fUserID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_t_Users_fUserPwd]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Users] DROP CONSTRAINT [DF_t_Users_fUserPwd]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_t_Users_fUserShortID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Users] DROP CONSTRAINT [DF_t_Users_fUserShortID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Users_fPurview]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Users] DROP CONSTRAINT [DF_Users_fPurview]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Users]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[Users]
GO
/****** Object:  Table [dbo].[Building]    Script Date: 04/25/2012 11:37:26 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Building_fGuid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Building] DROP CONSTRAINT [DF_Building_fGuid]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Building_fBuildingNo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Building] DROP CONSTRAINT [DF_Building_fBuildingNo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Building_fBuildingDesc]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Building] DROP CONSTRAINT [DF_Building_fBuildingDesc]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Building]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[Building]
GO
/****** Object:  Table [dbo].[PairingState]    Script Date: 04/25/2012 11:37:26 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PairingState_fAdscription]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PairingState] DROP CONSTRAINT [DF_PairingState_fAdscription]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_PairingState_fPairingType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PairingState] DROP CONSTRAINT [DF_PairingState_fPairingType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Table_1_fPairingStatus]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PairingState] DROP CONSTRAINT [DF_Table_1_fPairingStatus]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[PairingState]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[PairingState]
GO
/****** Object:  Table [dbo].[CheckoutDate]    Script Date: 04/25/2012 11:37:26 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Checkout_fCheckout]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[CheckoutDate] DROP CONSTRAINT [DF_Checkout_fCheckout]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[CheckoutDate]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[CheckoutDate]
GO
/****** Object:  Table [dbo].[Const]    Script Date: 04/25/2012 11:37:26 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_t_Const_fType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Const] DROP CONSTRAINT [DF_t_Const_fType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_t_Const_fTypeOrder]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Const] DROP CONSTRAINT [DF_t_Const_fTypeOrder]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_t_Const_fTypeDesc]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Const] DROP CONSTRAINT [DF_t_Const_fTypeDesc]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Const_fTypeFactValue]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Const] DROP CONSTRAINT [DF_Const_fTypeFactValue]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Const]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[Const]
GO
/****** Object:  Table [dbo].[Adscription]    Script Date: 04/25/2012 11:37:25 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Adscription_fAdscription]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Adscription] DROP CONSTRAINT [DF_Adscription_fAdscription]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Adscription_fDeviceType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Adscription] DROP CONSTRAINT [DF_Adscription_fDeviceType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Adscription_fSubnetID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Adscription] DROP CONSTRAINT [DF_Adscription_fSubnetID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Adscription_fDeviceID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Adscription] DROP CONSTRAINT [DF_Adscription_fDeviceID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Adscription_fNumber]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Adscription] DROP CONSTRAINT [DF_Adscription_fNumber]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Adscription]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[Adscription]
GO
/****** Object:  Table [dbo].[FileInfo]    Script Date: 04/25/2012 11:37:25 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fFileGUID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fFileGUID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fFileName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fFileName]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fFilePath]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fFilePath]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fFileExt]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fFileExt]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fFileSize]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fFileSize]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fFileOLE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fFileOLE]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fUploadBy]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fUploadBy]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_FileInfo_fUploadDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[FileInfo] DROP CONSTRAINT [DF_FileInfo_fUploadDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[FileInfo]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[FileInfo]
GO
/****** Object:  Table [dbo].[Log]    Script Date: 04/25/2012 11:37:25 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fCardNumber]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fCardNumber]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fIDNumber]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fIDNumber]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fHolderName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fHolderName]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fCardType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fCardType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fPermission]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fPermission]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fBuilding]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fBuilding]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fRoom]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fRoom]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fCheckInUser]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fCheckInUser]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fCheckInDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fCheckInDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_CheckIn_fCheckOutDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_CheckIn_fCheckOutDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Log_fIsBlackList]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Log] DROP CONSTRAINT [DF_Log_fIsBlackList]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Log]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[Log]
GO
/****** Object:  Table [dbo].[HotelCode]    Script Date: 04/25/2012 11:37:24 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_t_HotelInfo_HotelCode]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[HotelCode] DROP CONSTRAINT [DF_t_HotelInfo_HotelCode]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[HotelCode]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[HotelCode]
GO
/****** Object:  Table [dbo].[DoorAccessLog]    Script Date: 04/25/2012 11:37:24 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fBuilding]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fBuilding]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fRoom]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fRoom]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fDeleteDateFrom]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fDeleteDateFrom]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fDeleteDateTo]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fDeleteDateTo]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fCardNumber]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fCardNumber]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fCardType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fCardType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fHolderName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fHolderName]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fOpenDoorDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fOpenDoorDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fCreateBy]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fCreateBy]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DoorAccessLog_fCreateDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DoorAccessLog] DROP CONSTRAINT [DF_DoorAccessLog_fCreateDate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DoorAccessLog]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[DoorAccessLog]
GO
/****** Object:  Table [dbo].[KeyFunction]    Script Date: 04/25/2012 11:37:24 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_KeyFunction_fType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[KeyFunction] DROP CONSTRAINT [DF_KeyFunction_fType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_KeyFunction_fKeyFunctionID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[KeyFunction] DROP CONSTRAINT [DF_KeyFunction_fKeyFunctionID]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_KeyFunction_fKeyFunctionType]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[KeyFunction] DROP CONSTRAINT [DF_KeyFunction_fKeyFunctionType]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[KeyFunction]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[KeyFunction]
GO
/****** Object:  Table [dbo].[KeyFunction]    Script Date: 04/25/2012 11:37:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[KeyFunction]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[KeyFunction](
	[fType] [nvarchar](100) NOT NULL CONSTRAINT [DF_KeyFunction_fType]  DEFAULT (''),
	[fID] [int] NOT NULL CONSTRAINT [DF_KeyFunction_fKeyFunctionID]  DEFAULT (0),
	[fDescription] [nvarchar](100) NOT NULL CONSTRAINT [DF_KeyFunction_fKeyFunctionType]  DEFAULT ('')
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'KeyFunction', N'COLUMN',N'fType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'KeyFunction', @level2type=N'COLUMN',@level2name=N'fType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'KeyFunction', N'COLUMN',N'fID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'KeyFunction', @level2type=N'COLUMN',@level2name=N'fID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'KeyFunction', N'COLUMN',N'fDescription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'KeyFunction', @level2type=N'COLUMN',@level2name=N'fDescription'
GO
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 0, N'Invalid Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 89, N'Single Channel Lighting Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 95, N'Panel Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 3, N'AC Power')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 4, N'AC Cooling Setpoint')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 5, N'AC FAN Speed')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 6, N'AC Mode')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 7, N'AC Heating Setpoint')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 8, N'AC Auto Setpoint')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 9, N'Rise Temperature')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 10, N'Reduce Temperature')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 0, N'Invalid')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'On Off', 0, N'Off')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'On Off', 1, N'On')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC FAN Speed', 0, N'Auto')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC FAN Speed', 1, N'High')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC FAN Speed', 2, N'Medium')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC FAN Speed', 3, N'Low')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC Mode', 0, N'Cool')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC Mode', 1, N'Heat')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC Mode', 2, N'FAN')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC Mode', 3, N'Auto')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AC Mode', 4, N'Dry')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 85, N'Scene Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 86, N'Sequence Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 88, N'Universal Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 92, N'Curtain Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 94, N'SMS Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'SMS Control', 0, N'Invalid')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'SMS Control', 1, N'Message')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'SMS Control', 2, N'Remote')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 1, N'IR Receiver')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 2, N'Lock Key Of Panel')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 11, N'LCD Backlight')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 12, N'Lock AC Page')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 13, N'LED Backlight')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 14, N'LCD Status Light')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 15, N'Lock Button')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 16, N'Lock Page')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 17, N'Control Button Status')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 18, N'Control Button')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 19, N'Dry Temperature')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 20, N'Floor Heating Power')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 21, N'Floor Heating Mode')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Panel Control', 22, N'Goto Page')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Valid Invalid', 0, N'Invalid')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Valid Invalid', 1, N'Valid')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Floor Heating Mode', 1, N'Normal')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Floor Heating Mode', 2, N'Day')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Floor Heating Mode', 3, N'Night')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Floor Heating Mode', 4, N'Away')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Floor Heating Mode', 5, N'Auto')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 1, N'Vacation')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 2, N'Away')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 3, N'Night')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 4, N'Night With Guest')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 5, N'Day')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 6, N'Off/Disarm')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 7, N'Emergency')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 8, N'Fire')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 9, N'Panic')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Security Module', 10, N'Silent Panic')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 100, N'Broadcast Scene')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 101, N'Broadcast Channel')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 102, N'Security Module')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'AUX Power', 103, N'Zone-Audio 2')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Stop On Off', 0, N'Stop')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Stop On Off', 1, N'On')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Stop On Off', 2, N'Off')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Zone-Audio 2', 1, N'Source Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Zone-Audio 2', 2, N'Play Mode')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Zone-Audio 2', 3, N'Play List/Radio Channel')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Zone-Audio 2', 4, N'Play Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Zone-Audio 2', 5, N'Volume Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Zone-Audio 2', 6, N'Play Specify Song')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Source Control', 1, N'SD Card')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Source Control', 2, N'Audio In')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Source Control', 3, N'FTP Server')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Source Control', 4, N'FM Radio')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Mode', 1, N'No Repeat')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Mode', 2, N'Repeat Song')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Mode', 3, N'Continued')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Mode', 4, N'Repeat all')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play List/Radio Channel', 1, N'PREV Play List')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play List/Radio Channel', 2, N'Next Play List')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play List/Radio Channel', 3, N'Specify Play List No')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play List/Radio Channel', 4, N'PREV Radio Channel')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play List/Radio Channel', 5, N'Next Radio Channel')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play List/Radio Channel', 6, N'Specify Radio Channel No')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Control', 1, N'Prev Song')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Control', 2, N'Next Song')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Control', 3, N'Play')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Play Control', 4, N'Stop')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Volume Control', 1, N'VOL')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Volume Control', 2, N'TREBLE')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Volume Control', 3, N'BASS')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Reduce/Raise VOL', 1, N'Reduce VOL')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Reduce/Raise VOL', 2, N'Raise VOL')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Light', 85, N'Scene Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Light', 86, N'Sequence Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Light', 88, N'Universal Switch')
GO
print 'Processed 100 total records'
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Light', 89, N'Single Channel Lighting Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Light', 92, N'Curtain Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Light', 19, N'Reversing Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Curtain', 3, N'Invalid')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Light', 3, N'Invalid')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 3, N'Invalid')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 85, N'Scene Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 86, N'Sequence Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 88, N'Universal Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 89, N'Single Channel Lighting Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 92, N'Curtain Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 94, N'SMS Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 95, N'Panel Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 102, N'Security Module')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 103, N'Zone-Audio 2')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Mood', 19, N'Reversing Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Curtain', 88, N'Universal Switch')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Curtain', 89, N'Single Channel Lighting Control')
INSERT [dbo].[KeyFunction] ([fType], [fID], [fDescription]) VALUES (N'Bedside - Curtain', 92, N'Curtain Switch')
/****** Object:  Table [dbo].[DoorAccessLog]    Script Date: 04/25/2012 11:37:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DoorAccessLog]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[DoorAccessLog](
	[fBuilding] [nvarchar](50) NOT NULL CONSTRAINT [DF_DoorAccessLog_fBuilding]  DEFAULT (''),
	[fRoom] [nvarchar](50) NOT NULL CONSTRAINT [DF_DoorAccessLog_fRoom]  DEFAULT (''),
	[fDeleteDateFrom] [datetime] NOT NULL CONSTRAINT [DF_DoorAccessLog_fDeleteDateFrom]  DEFAULT (getdate()),
	[fDeleteDateTo] [datetime] NOT NULL CONSTRAINT [DF_DoorAccessLog_fDeleteDateTo]  DEFAULT (getdate()),
	[fCardNumber] [nvarchar](8) NOT NULL CONSTRAINT [DF_DoorAccessLog_fCardNumber]  DEFAULT (''),
	[fCardType] [nvarchar](20) NOT NULL CONSTRAINT [DF_DoorAccessLog_fCardType]  DEFAULT (''),
	[fHolderName] [nvarchar](100) NOT NULL CONSTRAINT [DF_DoorAccessLog_fHolderName]  DEFAULT (''),
	[fOpenDoorDate] [datetime] NOT NULL CONSTRAINT [DF_DoorAccessLog_fOpenDoorDate]  DEFAULT (getdate()),
	[fCreateBy] [nvarchar](20) NOT NULL CONSTRAINT [DF_DoorAccessLog_fCreateBy]  DEFAULT (''),
	[fCreateDate] [datetime] NOT NULL CONSTRAINT [DF_DoorAccessLog_fCreateDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_DoorAccessLog] PRIMARY KEY CLUSTERED 
(
	[fBuilding] ASC,
	[fRoom] ASC,
	[fCardNumber] ASC,
	[fOpenDoorDate] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fBuilding'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'幢' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fBuilding'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fRoom'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'房间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fRoom'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fDeleteDateFrom'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'删除时间范围(起)' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fDeleteDateFrom'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fDeleteDateTo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'删除时间范围(止)' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fDeleteDateTo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fCardNumber'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'卡号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fCardNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fCardType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'卡类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fCardType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fHolderName'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'持卡人' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fHolderName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fOpenDoorDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'开门时间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fOpenDoorDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fCreateBy'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'创建人' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fCreateBy'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DoorAccessLog', N'COLUMN',N'fCreateDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'创建时间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DoorAccessLog', @level2type=N'COLUMN',@level2name=N'fCreateDate'
GO
/****** Object:  Table [dbo].[HotelCode]    Script Date: 04/25/2012 11:37:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[HotelCode]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[HotelCode](
	[fHotelCode] [nvarchar](15) NOT NULL CONSTRAINT [DF_t_HotelInfo_HotelCode]  DEFAULT (''),
 CONSTRAINT [PK_HotelCode] PRIMARY KEY CLUSTERED 
(
	[fHotelCode] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'HotelCode', N'COLUMN',N'fHotelCode'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'酒店代码' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HotelCode', @level2type=N'COLUMN',@level2name=N'fHotelCode'
GO
INSERT [dbo].[HotelCode] ([fHotelCode]) VALUES (N'SMARTHOTEL')
/****** Object:  Table [dbo].[Log]    Script Date: 04/25/2012 11:37:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Log]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Log](
	[fCardNumber] [nvarchar](8) NOT NULL CONSTRAINT [DF_Log_CheckIn_fCardNumber]  DEFAULT (''),
	[fIDNumber] [nvarchar](100) NOT NULL CONSTRAINT [DF_Log_CheckIn_fIDNumber]  DEFAULT (''),
	[fHolderName] [nvarchar](100) NOT NULL CONSTRAINT [DF_Log_CheckIn_fHolderName]  DEFAULT (''),
	[fCardType] [nvarchar](20) NOT NULL CONSTRAINT [DF_Log_CheckIn_fCardType]  DEFAULT (''),
	[fPermission] [nvarchar](20) NOT NULL CONSTRAINT [DF_Log_CheckIn_fPermission]  DEFAULT (''),
	[fBuilding] [nvarchar](50) NOT NULL CONSTRAINT [DF_Log_CheckIn_fBuilding]  DEFAULT (''),
	[fRoom] [nvarchar](50) NOT NULL CONSTRAINT [DF_Log_CheckIn_fRoom]  DEFAULT (''),
	[fCheckInUser] [nvarchar](20) NOT NULL CONSTRAINT [DF_Log_CheckIn_fCheckInUser]  DEFAULT (''),
	[fCheckInDate] [datetime] NOT NULL CONSTRAINT [DF_Log_CheckIn_fCheckInDate]  DEFAULT (getdate()),
	[fCheckOutDate] [datetime] NOT NULL CONSTRAINT [DF_Log_CheckIn_fCheckOutDate]  DEFAULT (getdate()),
	[fFactCheckOutDate] [datetime] NULL,
	[fIsBlackList] [bit] NOT NULL CONSTRAINT [DF_Log_fIsBlackList]  DEFAULT (0)
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fCardNumber'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'IC卡编号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fCardNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fIDNumber'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'ID Number/Passport' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fIDNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fHolderName'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'持卡人姓名' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fHolderName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fCardType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'卡类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fCardType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fPermission'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'卡权限' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fPermission'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fBuilding'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'幢号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fBuilding'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fRoom'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'房间号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fRoom'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fCheckInUser'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'发卡人' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fCheckInUser'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fCheckInDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'Checkin日期' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fCheckInDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fCheckOutDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'Checkout日期' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fCheckOutDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fFactCheckOutDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'实际Checkout日期' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fFactCheckOutDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Log', N'COLUMN',N'fIsBlackList'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'是否在黑名单中' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Log', @level2type=N'COLUMN',@level2name=N'fIsBlackList'
GO
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'F232F977', N'Guest(288)', N'Guest(288)', N'Guest', N'One Room', N'Building A', N'288', N'Admin', CAST(0x0000A03800F91668 AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'92DAD277', N'Guest(388)', N'Guest(388)', N'Guest', N'One Room', N'Building A', N'388', N'Admin', CAST(0x0000A03800FFF30C AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'22C7C877', N'Guest(488)', N'Guest(488)', N'Guest', N'One Room', N'Building A', N'488', N'Admin', CAST(0x0000A03801001F94 AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'121AD077', N'Guest(588)', N'Guest(588)', N'Guest', N'One Room', N'Building A', N'588', N'Admin', CAST(0x0000A03801004E74 AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'8224DB77', N'Guest(688)', N'Guest(688)', N'Guest', N'One Room', N'Building A', N'688', N'Admin', CAST(0x0000A03801007AFC AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'8286CD77', N'Management(288)', N'Management(288)', N'Management', N'One Room', N'Building A', N'288', N'Admin', CAST(0x0000A0380106BA98 AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'C261D777', N'Management(388)', N'Management(388)', N'Management', N'One Room', N'Building A', N'388', N'Admin', CAST(0x0000A03801071F60 AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'E2ADB77', N'Management(488)', N'Management(488)', N'Management', N'One Room', N'Building A', N'488', N'Admin', CAST(0x0000A0380107415C AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'E2ADD977', N'Management(588)', N'Management(588)', N'Management', N'One Room', N'Building A', N'588', N'Admin', CAST(0x0000A03801076808 AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'F286D877', N'Management(688)', N'Management(688)', N'Management', N'One Room', N'Building A', N'688', N'Admin', CAST(0x0000A03801079A6C AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'32798D6D', N'Guest(888)', N'Guest(888)', N'Guest', N'One Room', N'Building A', N'888', N'Admin', CAST(0x0000A038010C7CD0 AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'8288A6D', N'Management(888)', N'Management(888)', N'Management', N'One Room', N'Building A', N'888', N'Admin', CAST(0x0000A038010C9ECC AS DateTime), CAST(0x0000A1A500D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'32798D6D', N'G12394943', N'Sam Jobs', N'Guest', N'One Room', N'Building A', N'888', N'admin', CAST(0x0000A03D013E8310 AS DateTime), CAST(0x0000A04700D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'32798D6D', N'G12394943', N'Sam Jobs', N'Guest', N'One Room', N'Building A', N'888', N'admin', CAST(0x0000A03D013EBED4 AS DateTime), CAST(0x0000A0A100D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'8288A6D', N'G23323332', N'Kate', N'Housekeeping', N'Floor Card', N'Building A', N'Eighth Floor', N'admin', CAST(0x0000A03D013FB294 AS DateTime), CAST(0x0000A1CD00D63BC0 AS DateTime), NULL, 0)
INSERT [dbo].[Log] ([fCardNumber], [fIDNumber], [fHolderName], [fCardType], [fPermission], [fBuilding], [fRoom], [fCheckInUser], [fCheckInDate], [fCheckOutDate], [fFactCheckOutDate], [fIsBlackList]) VALUES (N'8288A6D', N'G23323332', N'Kate', N'Housekeeping', N'Floor Card', N'Building A', N'Ninth Floor', N'admin', CAST(0x0000A03D013FB294 AS DateTime), CAST(0x0000A1CD00D63BC0 AS DateTime), NULL, 0)
/****** Object:  Table [dbo].[FileInfo]    Script Date: 04/25/2012 11:37:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[FileInfo]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[FileInfo](
	[fFileGuid] [uniqueidentifier] NOT NULL CONSTRAINT [DF_FileInfo_fFileGUID]  DEFAULT (newid()),
	[fFileName] [nvarchar](50) NOT NULL CONSTRAINT [DF_FileInfo_fFileName]  DEFAULT (''),
	[fFilePath] [nvarchar](100) NOT NULL CONSTRAINT [DF_FileInfo_fFilePath]  DEFAULT (''),
	[fFileExt] [nvarchar](10) NOT NULL CONSTRAINT [DF_FileInfo_fFileExt]  DEFAULT (''),
	[fFileSize] [bigint] NOT NULL CONSTRAINT [DF_FileInfo_fFileSize]  DEFAULT (0),
	[fFileOLE] [image] NOT NULL CONSTRAINT [DF_FileInfo_fFileOLE]  DEFAULT (''),
	[fUploadBy] [nvarchar](20) NOT NULL CONSTRAINT [DF_FileInfo_fUploadBy]  DEFAULT (''),
	[fUploadDate] [datetime] NOT NULL CONSTRAINT [DF_FileInfo_fUploadDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_FileInfo] PRIMARY KEY CLUSTERED 
(
	[fFileGuid] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fFileGuid'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'文件GUID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fFileGuid'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fFileName'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'文件名' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fFileName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fFilePath'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'文件路径' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fFilePath'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fFileExt'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'文件扩展名' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fFileExt'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fFileSize'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'文件大小' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fFileSize'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fFileOLE'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'上传的图片' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fFileOLE'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fUploadBy'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'上传用户' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fUploadBy'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FileInfo', N'COLUMN',N'fUploadDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'上传日期' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FileInfo', @level2type=N'COLUMN',@level2name=N'fUploadDate'
GO
INSERT [dbo].[FileInfo] ([fFileGuid], [fFileName], [fFilePath], [fFileExt], [fFileSize], [fFileOLE], [fUploadBy], [fUploadDate]) VALUES (N'bf9dbb1f-9cd3-4a91-b3e5-09171ae7a8cb', N'Door Bell.jpg', N'F:\Tommy\Project\DotNet\ICCard\ICCard\Picture\Door Bell.jpg', N'.jpg', 39954, [encoded data, 79910 characters], N'Tommy', CAST(0x00009FFA00AB6EE1 AS DateTime))
INSERT [dbo].[FileInfo] ([fFileGuid], [fFileName], [fFilePath], [fFileExt], [fFileSize], [fFileOLE], [fUploadBy], [fUploadDate]) VALUES (N'fddf7a2f-0766-402c-9783-2da9a189bb23', N'Mix Controller.jpg', N'F:\Tommy\Project\DotNet\ICCard\ICCard\Picture\Mix Controller.jpg', N'.jpg', 11512, [encoded data, 23026 characters], N'Tommy', CAST(0x00009FFA00ABF987 AS DateTime))
INSERT [dbo].[FileInfo] ([fFileGuid], [fFileName], [fFilePath], [fFileExt], [fFileSize], [fFileOLE], [fUploadBy], [fUploadDate]) VALUES (N'c7a56d6b-f9cf-46a5-a2b1-4889ef36afb5', N'Card Holder.jpg', N'F:\Tommy\Project\DotNet\ICCard\ICCard\Picture\Card Holder.jpg', N'.jpg', 24173, [encoded data, 48348 characters], N'Tommy', CAST(0x00009FFA00AB90F0 AS DateTime))
INSERT [dbo].[FileInfo] ([fFileGuid], [fFileName], [fFilePath], [fFileExt], [fFileSize], [fFileOLE], [fUploadBy], [fUploadDate]) VALUES (N'de06ea14-8629-4877-893c-86029ccdc7fb', N'AUX Power.jpg', N'F:\Tommy\Project\DotNet\ICCard\ICCard\Picture\AUX Power.jpg', N'.jpg', 16916, [encoded data, 33834 characters], N'Tommy', CAST(0x00009FFA00ABBC5F AS DateTime))
INSERT [dbo].[FileInfo] ([fFileGuid], [fFileName], [fFilePath], [fFileExt], [fFileSize], [fFileOLE], [fUploadBy], [fUploadDate]) VALUES (N'e735562a-2eeb-48e5-8d37-ca8ca8e229e7', N'Bedside.jpg', N'F:\Tommy\Project\DotNet\ICCard\ICCard\Picture\Bedside.jpg', N'.jpg', 67375, [encoded data, 134752 characters], N'Tommy', CAST(0x00009FFA00ABE0D4 AS DateTime))
INSERT [dbo].[FileInfo] ([fFileGuid], [fFileName], [fFilePath], [fFileExt], [fFileSize], [fFileOLE], [fUploadBy], [fUploadDate]) VALUES (N'ae4c8fc2-1427-47b8-8dfd-db914c60d6de', N'Logo.jpg', N'F:\Tommy\Project\DotNet\ICCard\ICCard\Picture\Logo.jpg', N'.jpg', 118580, [encoded data, 237162 characters], N'Tommy', CAST(0x00009FFA00AB01FD AS DateTime))
/****** Object:  Table [dbo].[Adscription]    Script Date: 04/25/2012 11:37:25 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Adscription]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Adscription](
	[fAdscription] [nvarchar](100) NOT NULL CONSTRAINT [DF_Adscription_fAdscription]  DEFAULT (''),
	[fDeviceType] [int] NOT NULL CONSTRAINT [DF_Adscription_fDeviceType]  DEFAULT (0),
	[fSubnetID] [int] NOT NULL CONSTRAINT [DF_Adscription_fSubnetID]  DEFAULT (1),
	[fDeviceID] [int] NOT NULL CONSTRAINT [DF_Adscription_fDeviceID]  DEFAULT (1),
	[fSerial] [int] NOT NULL CONSTRAINT [DF_Adscription_fNumber]  DEFAULT (0),
 CONSTRAINT [PK_Adscription] PRIMARY KEY CLUSTERED 
(
	[fAdscription] ASC,
	[fDeviceType] ASC,
	[fSubnetID] ASC,
	[fDeviceID] ASC,
	[fSerial] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Adscription', N'COLUMN',N'fAdscription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'归属房间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Adscription', @level2type=N'COLUMN',@level2name=N'fAdscription'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Adscription', N'COLUMN',N'fDeviceType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Adscription', @level2type=N'COLUMN',@level2name=N'fDeviceType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Adscription', N'COLUMN',N'fSubnetID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'子网ID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Adscription', @level2type=N'COLUMN',@level2name=N'fSubnetID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Adscription', N'COLUMN',N'fDeviceID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备ID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Adscription', @level2type=N'COLUMN',@level2name=N'fDeviceID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Adscription', N'COLUMN',N'fSerial'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'Bedside序列号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Adscription', @level2type=N'COLUMN',@level2name=N'fSerial'
GO
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'8100', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'8100', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'8100', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'8100', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'8100', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'8100', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'880', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'880', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'880', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'880', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'880', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'880', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'881', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'881', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'881', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'881', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'881', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'881', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'882', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'882', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'882', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'882', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'882', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'882', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'883', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'883', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'883', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'883', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'883', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'883', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'884', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'884', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'884', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'884', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'884', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'884', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'885', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'885', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'885', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'885', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'885', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'885', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'886', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'886', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'886', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'886', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'886', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'886', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'887', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'887', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'887', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'887', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'887', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'887', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'888', 5000, 1, 75, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'888', 5010, 1, 27, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'888', 5020, 1, 102, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'888', 5030, 1, 29, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'888', 5030, 1, 96, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'888', 5040, 1, 28, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'889', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'889', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'889', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'889', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'889', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'889', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'890', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'890', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'890', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'890', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'890', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'890', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'891', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'891', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'891', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'891', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'891', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'891', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'892', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'892', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'892', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'892', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'892', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'892', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'893', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'893', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'893', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'893', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'893', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'893', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'894', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'894', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'894', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'894', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'894', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'894', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'895', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'895', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'895', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'895', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'895', 5030, 0, 0, 2)
GO
print 'Processed 100 total records'
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'895', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'896', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'896', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'896', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'896', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'896', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'896', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'897', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'897', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'897', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'897', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'897', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'897', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'898', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'898', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'898', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'898', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'898', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'898', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'899', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'899', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'899', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'899', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'899', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'899', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'901', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'901', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'901', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'901', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'901', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'901', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'902', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'902', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'902', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'902', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'902', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'902', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'903', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'903', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'903', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'903', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'903', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'903', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'904', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'904', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'904', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'904', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'904', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'904', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'905', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'905', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'905', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'905', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'905', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'905', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'906', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'906', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'906', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'906', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'906', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'906', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'907', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'907', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'907', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'907', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'907', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'907', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'908', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'908', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'908', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'908', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'908', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'908', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'909', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'909', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'909', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'909', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'909', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'909', 5040, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'910', 5000, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'910', 5010, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'910', 5020, 0, 0, 0)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'910', 5030, 0, 0, 1)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'910', 5030, 0, 0, 2)
INSERT [dbo].[Adscription] ([fAdscription], [fDeviceType], [fSubnetID], [fDeviceID], [fSerial]) VALUES (N'910', 5040, 0, 0, 0)
/****** Object:  Table [dbo].[Const]    Script Date: 04/25/2012 11:37:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Const]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Const](
	[fType] [nvarchar](20) NOT NULL CONSTRAINT [DF_t_Const_fType]  DEFAULT (''),
	[fTypeOrder] [int] NOT NULL CONSTRAINT [DF_t_Const_fTypeOrder]  DEFAULT (0),
	[fTypeDesc] [nvarchar](100) NOT NULL CONSTRAINT [DF_t_Const_fTypeDesc]  DEFAULT (''),
	[fTypeFactValue] [int] NOT NULL CONSTRAINT [DF_Const_fTypeFactValue]  DEFAULT (0),
 CONSTRAINT [PK_Const] PRIMARY KEY CLUSTERED 
(
	[fType] ASC,
	[fTypeOrder] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Const', N'COLUMN',N'fType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'常量类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Const', @level2type=N'COLUMN',@level2name=N'fType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Const', N'COLUMN',N'fTypeOrder'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'顺序' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Const', @level2type=N'COLUMN',@level2name=N'fTypeOrder'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Const', N'COLUMN',N'fTypeDesc'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Const', @level2type=N'COLUMN',@level2name=N'fTypeDesc'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Const', N'COLUMN',N'fTypeFactValue'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'实际的值' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Const', @level2type=N'COLUMN',@level2name=N'fTypeFactValue'
GO
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 0, N'Guest', 1)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 1, N'Security', 2)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 2, N'Housekeeping', 3)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 3, N'Engineering', 4)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 4, N'Food & Beverage', 5)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 5, N'Butler private', 6)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 6, N'Management', 7)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Card Type', 7, N'Others', 8)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 0, N'Undefined', 0)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 1, N'Incandescent Lamp', 1)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 2, N'Magnetic Low-Votage Lamp', 2)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 3, N'Electronic Low-Voltage Lamp', 3)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 4, N'Fluorescent Lamp', 4)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 5, N'Neon/Cold Cathode Lamp', 5)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 6, N'High-Intensity Discharge(non-dim only) Lamp', 6)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Load Type', 7, N'Test', 7)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Permission', 0, N'One Room', 0)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Permission', 1, N'Multi-Rooms', 2)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Permission', 2, N'Floor Card', 1)
INSERT [dbo].[Const] ([fType], [fTypeOrder], [fTypeDesc], [fTypeFactValue]) VALUES (N'Permission', 3, N'Whole Hotel', 3)
/****** Object:  Table [dbo].[CheckoutDate]    Script Date: 04/25/2012 11:37:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[CheckoutDate]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[CheckoutDate](
	[fCheckout] [nvarchar](8) NOT NULL CONSTRAINT [DF_Checkout_fCheckout]  DEFAULT (N'12:00 PM')
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'CheckoutDate', N'COLUMN',N'fCheckout'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'默认Checkout时间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CheckoutDate', @level2type=N'COLUMN',@level2name=N'fCheckout'
GO
INSERT [dbo].[CheckoutDate] ([fCheckout]) VALUES (N'1:00 PM')
/****** Object:  Table [dbo].[PairingState]    Script Date: 04/25/2012 11:37:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[PairingState]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[PairingState](
	[fAdscription] [nvarchar](100) NOT NULL CONSTRAINT [DF_PairingState_fAdscription]  DEFAULT (''),
	[fPairingType] [nvarchar](100) NOT NULL CONSTRAINT [DF_PairingState_fPairingType]  DEFAULT (''),
	[fPairingState] [bit] NOT NULL CONSTRAINT [DF_Table_1_fPairingStatus]  DEFAULT (0),
 CONSTRAINT [PK_PairingState] PRIMARY KEY CLUSTERED 
(
	[fAdscription] ASC,
	[fPairingType] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'PairingState', N'COLUMN',N'fAdscription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'归属房间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PairingState', @level2type=N'COLUMN',@level2name=N'fAdscription'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'PairingState', N'COLUMN',N'fPairingType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'匹配类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PairingState', @level2type=N'COLUMN',@level2name=N'fPairingType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'PairingState', N'COLUMN',N'fPairingState'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'匹配结果 0:失败/未匹配 1:成功' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PairingState', @level2type=N'COLUMN',@level2name=N'fPairingState'
GO
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'8100', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'8100', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'8100', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'8100', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'8100', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'8100', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'8100', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'880', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'880', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'880', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'880', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'880', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'880', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'880', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'881', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'881', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'881', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'881', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'881', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'881', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'881', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'882', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'882', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'882', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'882', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'882', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'882', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'882', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'883', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'883', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'883', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'883', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'883', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'883', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'883', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'884', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'884', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'884', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'884', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'884', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'884', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'884', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'885', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'885', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'885', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'885', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'885', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'885', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'885', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'886', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'886', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'886', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'886', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'886', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'886', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'886', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'887', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'887', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'887', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'887', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'887', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'887', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'887', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'888', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'888', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'888', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'888', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'888', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'888', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'888', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'889', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'889', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'889', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'889', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'889', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'889', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'889', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'890', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'890', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'890', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'890', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'890', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'890', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'890', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'891', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'891', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'891', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'891', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'891', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'891', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'891', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'892', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'892', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'892', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'892', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'892', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'892', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'892', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'893', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'893', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'893', N'CardHolder_AUXPower', 0)
GO
print 'Processed 100 total records'
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'893', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'893', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'893', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'893', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'894', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'894', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'894', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'894', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'894', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'894', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'894', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'895', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'895', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'895', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'895', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'895', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'895', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'895', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'896', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'896', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'896', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'896', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'896', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'896', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'896', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'897', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'897', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'897', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'897', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'897', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'897', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'897', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'898', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'898', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'898', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'898', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'898', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'898', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'898', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'899', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'899', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'899', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'899', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'899', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'899', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'899', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'901', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'901', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'901', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'901', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'901', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'901', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'901', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'902', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'902', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'902', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'902', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'902', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'902', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'902', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'903', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'903', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'903', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'903', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'903', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'903', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'903', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'904', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'904', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'904', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'904', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'904', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'904', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'904', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'905', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'905', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'905', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'905', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'905', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'905', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'905', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'906', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'906', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'906', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'906', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'906', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'906', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'906', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'907', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'907', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'907', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'907', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'907', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'907', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'907', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'908', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'908', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'908', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'908', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'908', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'908', N'DoorBell_AUXPower', 0)
GO
print 'Processed 200 total records'
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'908', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'909', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'909', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'909', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'909', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'909', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'909', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'909', N'DoorBell_CardHolder', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'910', N'Bedside1_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'910', N'Bedside2_MixController', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'910', N'CardHolder_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'910', N'CardHolder_Bedside1', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'910', N'CardHolder_Bedside2', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'910', N'DoorBell_AUXPower', 0)
INSERT [dbo].[PairingState] ([fAdscription], [fPairingType], [fPairingState]) VALUES (N'910', N'DoorBell_CardHolder', 0)
/****** Object:  Table [dbo].[Building]    Script Date: 04/25/2012 11:37:26 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Building]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Building](
	[fGUID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Building_fGuid]  DEFAULT (newid()),
	[fBuildingNo] [int] NOT NULL CONSTRAINT [DF_Building_fBuildingNo]  DEFAULT (0),
	[fDescription] [nvarchar](50) NOT NULL CONSTRAINT [DF_Building_fBuildingDesc]  DEFAULT (''),
 CONSTRAINT [PK_Building] PRIMARY KEY CLUSTERED 
(
	[fGUID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Building', N'COLUMN',N'fGUID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'GUID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Building', @level2type=N'COLUMN',@level2name=N'fGUID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Building', N'COLUMN',N'fBuildingNo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'幢号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Building', @level2type=N'COLUMN',@level2name=N'fBuildingNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Building', N'COLUMN',N'fDescription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Building', @level2type=N'COLUMN',@level2name=N'fDescription'
GO
INSERT [dbo].[Building] ([fGUID], [fBuildingNo], [fDescription]) VALUES (N'97162fe2-4ff9-4a4e-ac3e-0a933e4a3aa7', 1, N'Building A')
/****** Object:  Table [dbo].[Users]    Script Date: 04/25/2012 11:37:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Users]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Users](
	[fUserID] [nvarchar](20) NOT NULL CONSTRAINT [DF_t_Users_fUserID]  DEFAULT (''),
	[fUserPwd] [nvarchar](20) NOT NULL CONSTRAINT [DF_t_Users_fUserPwd]  DEFAULT (''),
	[fUserShortID] [nvarchar](2) NOT NULL CONSTRAINT [DF_t_Users_fUserShortID]  DEFAULT (''),
	[fUserPurview] [int] NOT NULL CONSTRAINT [DF_Users_fPurview]  DEFAULT (1),
 CONSTRAINT [PK_t_Users_1] PRIMARY KEY CLUSTERED 
(
	[fUserID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Users', N'COLUMN',N'fUserID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'fUserID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Users', N'COLUMN',N'fUserPwd'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'用户密码' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'fUserPwd'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Users', N'COLUMN',N'fUserShortID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'用户简码' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'fUserShortID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Users', N'COLUMN',N'fUserPurview'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'用户权限' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'fUserPurview'
GO
INSERT [dbo].[Users] ([fUserID], [fUserPwd], [fUserShortID], [fUserPurview]) VALUES (N'admin', N'admin', N'sa', 1)
INSERT [dbo].[Users] ([fUserID], [fUserPwd], [fUserShortID], [fUserPurview]) VALUES (N'Debug', N'Debug', N'db', 2)
INSERT [dbo].[Users] ([fUserID], [fUserPwd], [fUserShortID], [fUserPurview]) VALUES (N'User', N'User', N'us', 3)
/****** Object:  Table [dbo].[Room]    Script Date: 04/25/2012 11:37:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Room]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Room](
	[fGUID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Room_fGUID]  DEFAULT (newid()),
	[fBuildingNo] [int] NOT NULL CONSTRAINT [DF_Room_fBuildingNo]  DEFAULT (1),
	[fFloorNo] [int] NOT NULL CONSTRAINT [DF_Room_fFloorNo]  DEFAULT (0),
	[fRoomNo] [int] NOT NULL CONSTRAINT [DF_Room_fRoomNo]  DEFAULT (1),
	[fDescription] [nvarchar](50) NOT NULL CONSTRAINT [DF_Room_fDescription]  DEFAULT (''),
 CONSTRAINT [PK_Room] PRIMARY KEY CLUSTERED 
(
	[fGUID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Room', N'COLUMN',N'fGUID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'GUID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Room', @level2type=N'COLUMN',@level2name=N'fGUID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Room', N'COLUMN',N'fBuildingNo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'幢号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Room', @level2type=N'COLUMN',@level2name=N'fBuildingNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Room', N'COLUMN',N'fFloorNo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'楼层号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Room', @level2type=N'COLUMN',@level2name=N'fFloorNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Room', N'COLUMN',N'fRoomNo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'房间号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Room', @level2type=N'COLUMN',@level2name=N'fRoomNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Room', N'COLUMN',N'fDescription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Room', @level2type=N'COLUMN',@level2name=N'fDescription'
GO
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'383b2892-c8e8-4aae-b9e8-02c0631f81f8', 1, 9, 2, N'902')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'b27bd429-61bb-4966-a674-09ebdb8ac4b8', 1, 8, 93, N'893')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'00739e33-8cc9-4426-91f7-13fa4de28d1c', 1, 8, 96, N'896')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'1430f2a5-b3bd-46c1-b10a-1f2adf1ad6ea', 1, 8, 92, N'892')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'0bc5d3ae-eb7b-41ed-8308-333b97315217', 1, 9, 6, N'906')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'685c9d71-7c64-472c-ad60-3a4ed90ec589', 1, 8, 83, N'883')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'08064610-331b-4189-9926-3b1df811b332', 1, 8, 95, N'895')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'b84544de-1b92-4d1d-b2f8-449bc6c77625', 1, 8, 97, N'897')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'b5a3ae29-fbcd-41db-8805-4a867a08c61e', 1, 8, 100, N'8100')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'f1c7d492-2fda-4002-8ff1-4c928fa7394d', 1, 9, 9, N'909')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'45f973c1-de81-4ebe-965b-5850e0ab60cb', 1, 8, 94, N'894')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'73edc32a-ae40-4c01-bae2-60ed861a4109', 1, 8, 98, N'898')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'af554435-e544-431f-9682-6c0b728e26bf', 1, 9, 1, N'901')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'5a1ecfff-7b58-4b46-9587-6ee2954517e5', 1, 8, 86, N'886')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'774006d3-67b5-4e2f-aec0-6f72fdc5bbf0', 1, 9, 8, N'908')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'e8f755bc-a985-4667-a397-717f135219d2', 1, 8, 99, N'899')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'b88965b8-ac2f-4dbb-af32-88665fa982b3', 1, 8, 84, N'884')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'553d5131-ed7a-4a36-8739-aa4d7fee3973', 1, 9, 7, N'907')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'19452df3-d51e-4d4c-96b8-acb99a9daf8a', 1, 8, 81, N'881')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'2bf5b0b0-1211-41fa-b971-ae94c5c5ef1f', 1, 9, 10, N'910')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'7bf9f0fa-7a5a-4f50-ab96-b291f462ff31', 1, 9, 4, N'904')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'5558d6eb-481f-40f7-8683-b7f2042cd88b', 1, 8, 88, N'888')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'ddaed37e-b6a0-4963-a523-b9645327fec6', 1, 8, 90, N'890')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'c648b1f7-2f45-497c-901b-bd8e94205d3e', 1, 8, 85, N'885')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'3753588c-2116-48ad-af1f-c75891969357', 1, 8, 80, N'880')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'1ccbfe3c-5270-42ac-8529-c882cd430950', 1, 8, 89, N'889')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'b62ca5f9-c787-4946-a531-c9af081ce106', 1, 9, 5, N'905')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'50920b4e-4c94-41c6-88b6-daa911f27f4f', 1, 9, 3, N'903')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'11354f6e-790e-4095-b074-dbe703406592', 1, 8, 87, N'887')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'be2fdf97-e708-4ba0-8cc3-f1709358aadd', 1, 8, 91, N'891')
INSERT [dbo].[Room] ([fGUID], [fBuildingNo], [fFloorNo], [fRoomNo], [fDescription]) VALUES (N'57c80e53-3783-46f4-977b-f25c42f19661', 1, 8, 82, N'882')
/****** Object:  Table [dbo].[Floor]    Script Date: 04/25/2012 11:37:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[Floor]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[Floor](
	[fGUID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Floor_fGUID]  DEFAULT (newid()),
	[fBuildingNo] [int] NOT NULL CONSTRAINT [DF_Floor_fBuildingNo]  DEFAULT (1),
	[fFloorNo] [int] NOT NULL CONSTRAINT [DF_Floor_fFloorNo]  DEFAULT (0),
	[fDescription] [nvarchar](50) NOT NULL CONSTRAINT [DF_Floor_ffDescription]  DEFAULT (''),
 CONSTRAINT [PK_Floor_1] PRIMARY KEY CLUSTERED 
(
	[fGUID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Floor', N'COLUMN',N'fGUID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'GUID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Floor', @level2type=N'COLUMN',@level2name=N'fGUID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Floor', N'COLUMN',N'fBuildingNo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'幢号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Floor', @level2type=N'COLUMN',@level2name=N'fBuildingNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Floor', N'COLUMN',N'fFloorNo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'楼层号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Floor', @level2type=N'COLUMN',@level2name=N'fFloorNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'Floor', N'COLUMN',N'fDescription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Floor', @level2type=N'COLUMN',@level2name=N'fDescription'
GO
INSERT [dbo].[Floor] ([fGUID], [fBuildingNo], [fFloorNo], [fDescription]) VALUES (N'01862db6-04e5-4818-bcc9-92d241704759', 1, 9, N'Ninth Floor')
INSERT [dbo].[Floor] ([fGUID], [fBuildingNo], [fFloorNo], [fDescription]) VALUES (N'29aa1b9e-ba6f-4d41-9c9e-dbcf0243e364', 1, 8, N'Eighth Floor')
/****** Object:  Table [dbo].[COM]    Script Date: 04/25/2012 11:37:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[COM]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[COM](
	[fCOMName] [nvarchar](5) NOT NULL CONSTRAINT [DF_COM_fCOMName]  DEFAULT (''),
	[fBaud] [int] NOT NULL CONSTRAINT [DF_COM_fBaud]  DEFAULT (0),
 CONSTRAINT [PK_COM] PRIMARY KEY CLUSTERED 
(
	[fCOMName] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'COM', N'COLUMN',N'fCOMName'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'串口名称' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'COM', @level2type=N'COLUMN',@level2name=N'fCOMName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'COM', N'COLUMN',N'fBaud'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'比特率' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'COM', @level2type=N'COLUMN',@level2name=N'fBaud'
GO
INSERT [dbo].[COM] ([fCOMName], [fBaud]) VALUES (N'COM1', 19200)
/****** Object:  Table [dbo].[CardInfo]    Script Date: 04/25/2012 11:37:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[CardInfo]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[CardInfo](
	[fCardNumber] [nvarchar](8) NOT NULL CONSTRAINT [DF_CardInfo_fCardNumber]  DEFAULT (''),
	[fPassword] [nvarchar](23) NOT NULL CONSTRAINT [DF_CardInfo_fNewPwd]  DEFAULT (''),
	[fRegisterBy] [nvarchar](20) NOT NULL CONSTRAINT [DF_CardInfo_fRegisterBy]  DEFAULT (''),
	[fRegisterDate] [datetime] NOT NULL CONSTRAINT [DF_CardInfo_fRegisterDate]  DEFAULT (getdate()),
	[fModifyBy] [nvarchar](20) NOT NULL CONSTRAINT [DF_CardInfo_fModifyBy]  DEFAULT (''),
	[fModifyDate] [datetime] NOT NULL CONSTRAINT [DF_CardInfo_fModifyDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_CardInfo] PRIMARY KEY CLUSTERED 
(
	[fCardNumber] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'CardInfo', N'COLUMN',N'fCardNumber'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'IC卡编号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CardInfo', @level2type=N'COLUMN',@level2name=N'fCardNumber'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'CardInfo', N'COLUMN',N'fPassword'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'IC卡新密码(255,255,255,255,255,255)' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CardInfo', @level2type=N'COLUMN',@level2name=N'fPassword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'CardInfo', N'COLUMN',N'fRegisterBy'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'登记卡的用户' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CardInfo', @level2type=N'COLUMN',@level2name=N'fRegisterBy'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'CardInfo', N'COLUMN',N'fRegisterDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'登记卡的时间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CardInfo', @level2type=N'COLUMN',@level2name=N'fRegisterDate'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'CardInfo', N'COLUMN',N'fModifyBy'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'修改卡密码的用户' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CardInfo', @level2type=N'COLUMN',@level2name=N'fModifyBy'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'CardInfo', N'COLUMN',N'fModifyDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'修改卡密码的时间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CardInfo', @level2type=N'COLUMN',@level2name=N'fModifyDate'
GO
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'121AD077', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A0380100AF1A AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'22C7C877', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A03801008014 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'32798D6D', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A00C00BE441F AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'423F8D6D', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A032010640CA AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'8224DB77', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A0380100DBA2 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'82678D6D', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A00C00E8B1A0 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'8286CD77', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A03801071AE4 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'8288A6D', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A035011CF2E6 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'92DAD277', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A038010053C4 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'A2208A6D', N'255,255,255,255,255,255', N'Admin', CAST(0x00009FD600AACA4A AS DateTime), N'Admin', CAST(0x00009FD500F92790 AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'C261D777', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A03801078035 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'E24C3D6F', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A00400FE8E75 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'E2ADB77', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A0380107A1EF AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'E2ADD977', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A0380107C902 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'F232F977', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A03800F97775 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'F23F8D6D', N'255,255,255,255,255,255', N'Admin', CAST(0x00009FD500F33660 AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
INSERT [dbo].[CardInfo] ([fCardNumber], [fPassword], [fRegisterBy], [fRegisterDate], [fModifyBy], [fModifyDate]) VALUES (N'F286D877', N'255,255,255,255,255,255', N'Admin', CAST(0x0000A0380107FB8B AS DateTime), N'Admin', CAST(0x00009FF20106974A AS DateTime))
/****** Object:  Table [dbo].[HotelPwd]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[HotelPwd]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[HotelPwd](
	[fOldPwd] [nvarchar](23) NOT NULL CONSTRAINT [DF_HotelPwd_fOldPwd]  DEFAULT (''),
	[fNewPwd] [nvarchar](23) NOT NULL CONSTRAINT [DF_HotelPwd_fNewPwd]  DEFAULT (''),
	[fModifyBy] [nvarchar](20) NOT NULL CONSTRAINT [DF_HotelPwd_fModifyBy]  DEFAULT (''),
	[fModifyDate] [datetime] NOT NULL CONSTRAINT [DF_HotelPwd_fModifyDate]  DEFAULT (getdate())
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'HotelPwd', N'COLUMN',N'fOldPwd'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'酒店原密码' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HotelPwd', @level2type=N'COLUMN',@level2name=N'fOldPwd'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'HotelPwd', N'COLUMN',N'fNewPwd'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'酒店新密码' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HotelPwd', @level2type=N'COLUMN',@level2name=N'fNewPwd'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'HotelPwd', N'COLUMN',N'fModifyBy'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'修改人员' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HotelPwd', @level2type=N'COLUMN',@level2name=N'fModifyBy'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'HotelPwd', N'COLUMN',N'fModifyDate'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'修改时间' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HotelPwd', @level2type=N'COLUMN',@level2name=N'fModifyDate'
GO
INSERT [dbo].[HotelPwd] ([fOldPwd], [fNewPwd], [fModifyBy], [fModifyDate]) VALUES (N'255,255,255,255,255,255', N'255,255,255,255,255,255', N'Admin', CAST(0x00009FF20106974A AS DateTime))
/****** Object:  Table [dbo].[OnlineDevice]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[OnlineDevice]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[OnlineDevice](
	[fDeviceType] [int] NOT NULL CONSTRAINT [DF_OnlineDevice_fDeviceType]  DEFAULT (0),
	[fSubnetID] [int] NOT NULL CONSTRAINT [DF_OnlineDevice_fSubnetID]  DEFAULT (1),
	[fDeviceID] [int] NOT NULL CONSTRAINT [DF_OnlineDevice_fDeviceID]  DEFAULT (1),
	[fMAC] [nvarchar](23) NOT NULL CONSTRAINT [DF_OnlineDevice_fMAC]  DEFAULT ('??.??.??.??.??.??.??.??'),
	[fRemark] [nvarchar](500) NOT NULL CONSTRAINT [DF_OnlineDevice_fRemark]  DEFAULT (''),
 CONSTRAINT [PK_OnlineDevice] PRIMARY KEY CLUSTERED 
(
	[fDeviceType] ASC,
	[fSubnetID] ASC,
	[fDeviceID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'OnlineDevice', N'COLUMN',N'fDeviceType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OnlineDevice', @level2type=N'COLUMN',@level2name=N'fDeviceType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'OnlineDevice', N'COLUMN',N'fSubnetID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'子网ID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OnlineDevice', @level2type=N'COLUMN',@level2name=N'fSubnetID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'OnlineDevice', N'COLUMN',N'fDeviceID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备ID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OnlineDevice', @level2type=N'COLUMN',@level2name=N'fDeviceID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'OnlineDevice', N'COLUMN',N'fMAC'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'MAC地址' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OnlineDevice', @level2type=N'COLUMN',@level2name=N'fMAC'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'OnlineDevice', N'COLUMN',N'fRemark'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'OnlineDevice', @level2type=N'COLUMN',@level2name=N'fRemark'
GO
INSERT [dbo].[OnlineDevice] ([fDeviceType], [fSubnetID], [fDeviceID], [fMAC], [fRemark]) VALUES (5030, 1, 96, N'4A.4F.53.58.5D.61.66.6A', N'')
/****** Object:  Table [dbo].[DeviceType]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[DeviceType]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[DeviceType](
	[fDeviceType] [int] NOT NULL CONSTRAINT [DF_DeviceType_fDeviceType]  DEFAULT (0),
	[fDeviceName] [nvarchar](50) NOT NULL CONSTRAINT [DF_DeviceType_fDeviceName]  DEFAULT ('Unknow'),
	[fModel] [nvarchar](500) NOT NULL CONSTRAINT [DF_DeviceType_fModel]  DEFAULT (''),
	[fDescription] [nvarchar](500) NOT NULL CONSTRAINT [DF_DeviceType_fDescriptionEng]  DEFAULT (''),
 CONSTRAINT [PK_DeviceType] PRIMARY KEY CLUSTERED 
(
	[fDeviceType] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DeviceType', N'COLUMN',N'fDeviceType'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备类型' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DeviceType', @level2type=N'COLUMN',@level2name=N'fDeviceType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DeviceType', N'COLUMN',N'fDeviceName'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备标识' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DeviceType', @level2type=N'COLUMN',@level2name=N'fDeviceName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DeviceType', N'COLUMN',N'fModel'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备型号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DeviceType', @level2type=N'COLUMN',@level2name=N'fModel'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'DeviceType', N'COLUMN',N'fDescription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'设备描述(英文)' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'DeviceType', @level2type=N'COLUMN',@level2name=N'fDescription'
GO
INSERT [dbo].[DeviceType] ([fDeviceType], [fDeviceName], [fModel], [fDescription]) VALUES (5000, N'Door Bell', N'SB-3SBXS-WL', N'Hotel Door Access Bell')
INSERT [dbo].[DeviceType] ([fDeviceType], [fDeviceName], [fModel], [fDescription]) VALUES (5010, N'Card Holder', N'SB-3SCARD-WL', N'Hotel Card Holder')
INSERT [dbo].[DeviceType] ([fDeviceType], [fDeviceName], [fModel], [fDescription]) VALUES (5020, N'Mix Controller', N'SB-ZMIX23-DN', N'Hotel Mix Controller')
INSERT [dbo].[DeviceType] ([fDeviceType], [fDeviceName], [fModel], [fDescription]) VALUES (5030, N'Bedside', N'SB-BEDSD-UN', N'Hotel Bedside')
INSERT [dbo].[DeviceType] ([fDeviceType], [fDeviceName], [fModel], [fDescription]) VALUES (5040, N'AUX Power', N'SB-HAUX-WL', N'Hotel AUX Power')
/****** Object:  Table [dbo].[FloorDefinition]    Script Date: 04/25/2012 11:37:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[FloorDefinition]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[FloorDefinition](
	[fGUID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_FloorDefinition_fGUID]  DEFAULT (newid()),
	[fFloorNo] [int] NOT NULL CONSTRAINT [DF_FloorDefinition_fFloorNo]  DEFAULT (0),
	[fDescription] [nvarchar](50) NOT NULL CONSTRAINT [DF_FloorDefinition_fDescription]  DEFAULT (''),
 CONSTRAINT [PK_FloorDefinition] PRIMARY KEY CLUSTERED 
(
	[fGUID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FloorDefinition', N'COLUMN',N'fGUID'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'GUID' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FloorDefinition', @level2type=N'COLUMN',@level2name=N'fGUID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FloorDefinition', N'COLUMN',N'fFloorNo'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'楼层号' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FloorDefinition', @level2type=N'COLUMN',@level2name=N'fFloorNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'USER',N'dbo', N'TABLE',N'FloorDefinition', N'COLUMN',N'fDescription'))
EXEC dbo.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'FloorDefinition', @level2type=N'COLUMN',@level2name=N'fDescription'
GO
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'890011cf-51e5-4462-9aa5-12531d3d2ad7', 3, N'Third Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'267882af-7dae-429b-8897-132d0f9723cb', 2, N'Second Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'eadbf4c7-568a-4e03-80c0-2f3608bb9448', 1, N'First Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'eec0a513-df06-4cae-b2e6-2ff806be2ce9', 0, N'Ground Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'31b1dcce-4bec-4d8f-be52-3cfd05a63da2', 6, N'Sixth Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'147cebec-23ec-4c96-b943-5d6e7e1c104a', 9, N'Ninth Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'd5555a3e-e47e-4db5-8d55-c326e202dc7d', 8, N'Eighth Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'1ac1afbf-d802-425e-8a59-ce6a92b0f571', 4, N'Fourth Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'd190467f-40bf-486a-b379-f4e7b6b93e0a', 5, N'Fifth Floor')
INSERT [dbo].[FloorDefinition] ([fGUID], [fFloorNo], [fDescription]) VALUES (N'2b6f8fd1-e611-4ca2-9739-f544e4192307', 7, N'Seventh Floor')
/****** Object:  Trigger [tr_DeviceType]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[tr_DeviceType]') AND OBJECTPROPERTY(id, N'IsTrigger') = 1)
EXEC dbo.sp_executesql @statement = N'CREATE TRIGGER [dbo].[tr_DeviceType]
ON
    [dbo].[DeviceType]
FOR
    UPDATE
AS
BEGIN
    IF EXISTS(SELECT * FROM Inserted)
    BEGIN
        IF EXISTS(SELECT * FROM Deleted)    --Update
        BEGIN
            UPDATE
                [dbo].[Adscription]
            SET
                fDeviceType = C.fDeviceType
            FROM
                [dbo].[Adscription] A
            JOIN
                Deleted B
            ON
                A.fDeviceType = B.fDeviceType
            JOIN
                Inserted C
            ON
                B.fDeviceType <> C.fDeviceType
        END
    END
END
'
GO
/****** Object:  Trigger [tr_Room]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[tr_Room]') AND OBJECTPROPERTY(id, N'IsTrigger') = 1)
EXEC dbo.sp_executesql @statement = N'CREATE TRIGGER [dbo].[tr_Room]
ON
    [dbo].[Room]
FOR
    INSERT, DELETE, UPDATE
AS
BEGIN
    DECLARE @DEVICE_DOORBELL      INT,
            @DEVICE_CARDHOLDER    INT,
            @DEVICE_MIXCONTROLLER INT,
            @DEVICE_BEDSIDE       INT,
            @DEVICE_AUXPOWER      INT
    
    SET @DEVICE_DOORBELL      = (SELECT fDeviceType FROM [dbo].[DeviceType] WHERE fDeviceName = ''Door Bell'')
    SET @DEVICE_CARDHOLDER    = (SELECT fDeviceType FROM [dbo].[DeviceType] WHERE fDeviceName = ''Card Holder'')
    SET @DEVICE_MIXCONTROLLER = (SELECT fDeviceType FROM [dbo].[DeviceType] WHERE fDeviceName = ''Mix Controller'')
    SET @DEVICE_BEDSIDE       = (SELECT fDeviceType FROM [dbo].[DeviceType] WHERE fDeviceName = ''Bedside'')
    SET @DEVICE_AUXPOWER      = (SELECT fDeviceType FROM [dbo].[DeviceType] WHERE fDeviceName = ''AUX Power'')
    
    IF NOT EXISTS(SELECT * FROM Inserted)    --Delete
    BEGIN
        --Table Adscription
        DELETE
            [dbo].[Adscription]
        FROM
            [dbo].[Adscription] A
        JOIN
            Deleted B
        ON
            A.fAdscription = B.fDescription
        
        --Table PairingState
        DELETE
            [dbo].[PairingState]
        FROM
            [dbo].[PairingState] A
        JOIN
            Deleted B
        ON
            A.fAdscription = B.fDescription
    END
    ELSE
    BEGIN
        IF EXISTS(SELECT * FROM Deleted)    --Update
        BEGIN
            IF UPDATE(fDescription)
            BEGIN
                --Table Adscription
                UPDATE
                    [dbo].[Adscription]
                SET
                    fAdscription = C.fDescription
                FROM
                    [dbo].[Adscription] A
                JOIN
                    Deleted B
                ON
                    A.fAdscription = B.fDescription
                JOIN
                    Inserted C
                ON
                    B.fDescription <> C.fDescription
                
                --Table PairingState
                UPDATE
                    [dbo].[PairingState]
                SET
                    fAdscription = C.fDescription
                FROM
                    [dbo].[PairingState] A
                JOIN
                    Deleted B
                ON
                    A.fAdscription = B.fDescription
                JOIN
                    Inserted C
                ON
                    B.fDescription <> C.fDescription
            END
        END
        ELSE                                --Insert
        BEGIN
            --Table Adscription
            INSERT INTO [dbo].[Adscription]
                SELECT fDescription, @DEVICE_DOORBELL, 0, 0, 0 FROM Inserted
            INSERT INTO [dbo].[Adscription]
                SELECT fDescription, @DEVICE_CARDHOLDER, 0, 0, 0 FROM Inserted
            INSERT INTO [dbo].[Adscription]
                SELECT fDescription, @DEVICE_MIXCONTROLLER, 0, 0, 0 FROM Inserted
            INSERT INTO [dbo].[Adscription]
                SELECT fDescription, @DEVICE_BEDSIDE, 0, 0, 1 FROM Inserted
            INSERT INTO [dbo].[Adscription]
                SELECT fDescription, @DEVICE_BEDSIDE, 0, 0, 2 FROM Inserted
            INSERT INTO [dbo].[Adscription]
                SELECT fDescription, @DEVICE_AUXPOWER, 0, 0, 0 FROM Inserted
            
            --Table PairingState
            INSERT INTO [dbo].[PairingState]
                SELECT fDescription, ''DoorBell_CardHolder'', 0 FROM Inserted
            INSERT INTO [dbo].[PairingState]
                SELECT fDescription, ''DoorBell_AUXPower'', 0 FROM Inserted
            INSERT INTO [dbo].[PairingState]
                SELECT fDescription, ''CardHolder_Bedside1'', 0 FROM Inserted
            INSERT INTO [dbo].[PairingState]
                SELECT fDescription, ''CardHolder_Bedside2'', 0 FROM Inserted
            INSERT INTO [dbo].[PairingState]
                SELECT fDescription, ''CardHolder_AUXPower'', 0 FROM Inserted
            INSERT INTO [dbo].[PairingState]
                SELECT fDescription, ''Bedside1_MixController'', 0 FROM Inserted
            INSERT INTO [dbo].[PairingState]
                SELECT fDescription, ''Bedside2_MixController'', 0 FROM Inserted
        END
    END
END
'
GO
/****** Object:  Trigger [tr_Building]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[tr_Building]') AND OBJECTPROPERTY(id, N'IsTrigger') = 1)
EXEC dbo.sp_executesql @statement = N'CREATE TRIGGER [dbo].[tr_Building]
ON
    [dbo].[Building]
FOR
    DELETE, UPDATE
AS
BEGIN
    IF NOT EXISTS(SELECT * FROM Inserted)    --Delete
    BEGIN
        DELETE
            [dbo].[Floor]
        FROM
            [dbo].[Floor] A
        JOIN
            Deleted B
        ON
            A.fBuildingNo = B.fBuildingNo
    END
    ELSE
    BEGIN
        IF EXISTS(SELECT * FROM Deleted)    --Update
        BEGIN
            IF UPDATE(fBuildingNo)
            BEGIN
                UPDATE
                    [dbo].[Floor]
                SET
                    fBuildingNo = C.fBuildingNo
                FROM
                    [dbo].[Floor] A
                JOIN
                    Deleted B
                ON
                    A.fBuildingNo = B.fBuildingNo
                JOIN
                    Inserted C
                ON
                    B.fBuildingNo <> C.fBuildingNo
            END
        END
    END
END
'
GO
/****** Object:  Trigger [tr_FloorDefinition]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[tr_FloorDefinition]') AND OBJECTPROPERTY(id, N'IsTrigger') = 1)
EXEC dbo.sp_executesql @statement = N'CREATE TRIGGER [dbo].[tr_FloorDefinition]
ON
    [dbo].[FloorDefinition]
FOR
    DELETE
AS
BEGIN
    IF NOT EXISTS(SELECT * FROM Inserted)    --Delete
    BEGIN
        DELETE
            [dbo].[Floor]
        FROM
            [dbo].[Floor] A
        JOIN
            Deleted B
        ON
            A.fFloorNo = B.fFloorNo
    END
END
'
GO
/****** Object:  Trigger [tr_Floor]    Script Date: 04/25/2012 11:37:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[tr_Floor]') AND OBJECTPROPERTY(id, N'IsTrigger') = 1)
EXEC dbo.sp_executesql @statement = N'CREATE TRIGGER [dbo].[tr_Floor]
ON
    [dbo].[Floor]
FOR
    DELETE, UPDATE
AS
BEGIN
    IF NOT EXISTS(SELECT * FROM Inserted)    --Delete
    BEGIN
        DELETE
            [dbo].[Room]
        FROM
            [dbo].[Room] A
        JOIN
            Deleted B
        ON
            A.fBuildingNo = B.fBuildingNo
        AND
            A.fFloorNo = B.fFloorNo
    END
    ELSE
    BEGIN
        IF EXISTS(SELECT * FROM Deleted)    --Update
        BEGIN
            IF UPDATE(fBuildingNo) OR UPDATE(fFloorNo)
            BEGIN
                UPDATE
                    [dbo].[Room]
                SET
                    fBuildingNo = C.fBuildingNo,
                    fFloorNo = C.fFloorNo
                FROM
                    [dbo].[Room] A
                JOIN
                    Deleted B
                ON
                    A.fBuildingNo = B.fBuildingNo
                AND
                    A.fFloorNo = B.fFloorNo
                JOIN
                    Inserted C
                ON
                    B.fBuildingNo <> C.fBuildingNo
                OR
                    B.fFloorNo <> C.fFloorNo
            END
        END
    END
END
'
GO
