if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_T_Base_Device_T_Base_Device_Kind]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[T_Base_Device] DROP CONSTRAINT FK_T_Base_Device_T_Base_Device_Kind
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_T_Base_Route_Detail_T_Base_Route_Kind]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[T_Base_Route_Detail] DROP CONSTRAINT FK_T_Base_Route_Detail_T_Base_Route_Kind
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_T_ITEMTASKTYPE_RouteKind_T_Base_Route_Kind]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[T_ITEMTASKTYPE_RouteKind] DROP CONSTRAINT FK_T_ITEMTASKTYPE_RouteKind_T_Base_Route_Kind
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[V_DeviceCommand]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[V_DeviceCommand]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[V_Manage_Task]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[V_Manage_Task]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[V_Monitor_Task]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[V_Monitor_Task]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[IO_CONTROL]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[IO_CONTROL]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Device]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Device]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Device_Command]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Device_Command]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Device_Kind]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Device_Kind]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Device_State]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Device_State]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Device_Valid_Command]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Device_Valid_Command]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Manage_Task]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Manage_Task]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Manage_Task_Kind]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Manage_Task_Kind]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Monitor_Task]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Monitor_Task]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Route_Detail]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Route_Detail]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_Base_Route_Kind]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_Base_Route_Kind]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_ITEMDEVICESTATION]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_ITEMDEVICESTATION]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_ITEMTASKTYPE_RouteKind]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[T_ITEMTASKTYPE_RouteKind]
GO

CREATE TABLE [dbo].[IO_CONTROL] (
	[FID] [int] NULL ,
	[FPLANID] [int] NULL ,
	[FMANAGEID] [int] NULL ,
	[FTASKTYPE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FTASKLEVEL] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FISRETURN] [int] NULL ,
	[FWAREHOUSE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTARTPOSITION] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTARTSITE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FENDPOSITION] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FENDSITE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTOCKCODE] [varchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTATUS] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FBEGTIME] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FENDTIME] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FDEVICESTATUS] [int] NULL ,
	[FDEVICEFLOW] [int] NULL ,
	[FREMARK] [varchar] (500) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Device] (
	[F_DeviceIndex] [int] NOT NULL ,
	[F_DeviceKindIndex] [int] NULL ,
	[F_DeviceName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_CommType] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_DBWAddress] [int] NULL ,
	[F_DBWSendLength] [int] NULL ,
	[F_DBWGetLength] [decimal](10, 4) NULL ,
	[F_SerialPort] [int] NULL ,
	[F_CommSettings] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_LockedState] [int] NULL ,
	[F_DeviceVisual] [int] NULL ,
	[F_ClientIndex] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Device_Command] (
	[F_DeviceKindIndex] [int] NOT NULL ,
	[F_DeviceCommandIndex] [int] NOT NULL ,
	[F_DeviceCommandName] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Device_Kind] (
	[F_DeviceKindIndex] [int] NOT NULL ,
	[F_GoodsMoveKindIndex] [int] NOT NULL ,
	[F_DeviceKindName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Device_State] (
	[F_StateIndex] [int] NOT NULL ,
	[F_StateName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Device_Valid_Command] (
	[F_DeviceIndex] [int] NOT NULL ,
	[F_DeviceKindIndex] [int] NOT NULL ,
	[F_DeviceCommandIndex] [int] NOT NULL ,
	[F_ParamCount] [int] NOT NULL ,
	[F_ControlFillKind] [varchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[F_IdentifyName] [varchar] (80) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Manage_Task] (
	[FID] [int] NOT NULL ,
	[F_ManageTaskKindIndex] [int] NOT NULL ,
	[FTASKTYPE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FTASKLEVEL] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FISRETURN] [char] (1) COLLATE Chinese_PRC_CI_AS NULL ,
	[FWAREHOUSE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTARTPOSITION] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTARTSITE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FENDPOSITION] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FENDSITE] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTOCKCODE] [varchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[FSTATUS] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FBEGTIME] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FENDTIME] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[FDEVICESTATUS] [int] NULL ,
	[FDEVICEFLOW] [int] NULL ,
	[FREMARK] [varchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[FIntoStepOK] [char] (1) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Manage_Task_Kind] (
	[F_TaskKindIndex] [int] NOT NULL ,
	[F_TaskKindName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Monitor_Task] (
	[F_ManageTaskIndex] [int] NOT NULL ,
	[F_ManageTaskKindIndex] [int] NOT NULL ,
	[F_MonitorIndex] [int] NOT NULL ,
	[F_MonitorTaskLevel] [int] NULL ,
	[F_DeviceIndex] [int] NULL ,
	[F_DeviceCommandIndex] [int] NULL ,
	[F_RouteKindIndex] [int] NULL ,
	[F_Status] [int] NULL ,
	[F_DeviceStateIndex] [int] NULL ,
	[F_StartTime] [nvarchar] (8) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_EndTime] [nvarchar] (8) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_NumParam1] [int] NULL ,
	[F_NumParam2] [int] NULL ,
	[F_NumParam3] [int] NULL ,
	[F_NumParam4] [int] NULL ,
	[F_NumParam5] [int] NULL ,
	[F_NumParam6] [int] NULL ,
	[F_TxtParam] [varchar] (900) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Route_Detail] (
	[F_RouteKindIndex] [int] NOT NULL ,
	[F_RouteDetailIndex] [int] NOT NULL ,
	[F_DeviceIndex] [int] NULL ,
	[F_EndNode] [char] (1) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_Orders] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_WaitPallet] [char] (1) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_AheadDetect] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_AssociateDeviceIndex] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_LockedDeviceIndex] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_Base_Route_Kind] (
	[F_RouteKindIndex] [int] NOT NULL ,
	[F_RouteKind] [int] NOT NULL ,
	[F_RouteIndex] [int] NOT NULL ,
	[F_RouteName] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_ITEMDEVICESTATION] (
	[FCODE] [int] NOT NULL ,
	[FNAME] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FDESCRIPTION] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FWAREHOUSE] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FLANEWAYCODE] [int] NULL 
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[T_ITEMTASKTYPE_RouteKind] (
	[FCODE] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FINTERCODE] [char] (1) COLLATE Chinese_PRC_CI_AS NULL ,
	[FRELATIVECODE] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[FNAME] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[F_RouteKindIndex] [int] NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[T_Base_Device] WITH NOCHECK ADD 
	CONSTRAINT [PK__T_Base_Device__1DE57479] PRIMARY KEY  CLUSTERED 
	(
		[F_DeviceIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Device_Command] WITH NOCHECK ADD 
	CONSTRAINT [PK_T_Base_Device_Command] PRIMARY KEY  CLUSTERED 
	(
		[F_DeviceKindIndex],
		[F_DeviceCommandIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Device_Kind] WITH NOCHECK ADD 
	 PRIMARY KEY  CLUSTERED 
	(
		[F_DeviceKindIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Device_State] WITH NOCHECK ADD 
	 PRIMARY KEY  CLUSTERED 
	(
		[F_StateIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Manage_Task] WITH NOCHECK ADD 
	CONSTRAINT [PK_T_Base_Manage_Task] PRIMARY KEY  CLUSTERED 
	(
		[FID],
		[F_ManageTaskKindIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Manage_Task_Kind] WITH NOCHECK ADD 
	 PRIMARY KEY  CLUSTERED 
	(
		[F_TaskKindIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Monitor_Task] WITH NOCHECK ADD 
	CONSTRAINT [PK_T_Base_Monitor_Task] PRIMARY KEY  CLUSTERED 
	(
		[F_MonitorIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Route_Detail] WITH NOCHECK ADD 
	CONSTRAINT [PK_T_RouteDetail] PRIMARY KEY  CLUSTERED 
	(
		[F_RouteDetailIndex],
		[F_RouteKindIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_Base_Route_Kind] WITH NOCHECK ADD 
	CONSTRAINT [PK_T_Base_Route] PRIMARY KEY  CLUSTERED 
	(
		[F_RouteKindIndex]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_ITEMDEVICESTATION] WITH NOCHECK ADD 
	CONSTRAINT [PK_T_ITEMDEVICESTATION] PRIMARY KEY  CLUSTERED 
	(
		[FCODE]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[T_ITEMTASKTYPE_RouteKind] WITH NOCHECK ADD 
	CONSTRAINT [PK_T_ITEMTASKTYPE_RouteKind] PRIMARY KEY  CLUSTERED 
	(
		[FCODE]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[IO_CONTROL] ADD 
	CONSTRAINT [DF_IO_CONTROL_FTASKLEVEL] DEFAULT (1) FOR [FTASKLEVEL],
	CONSTRAINT [DF_IO_CONTROL_FWAREHOUSE] DEFAULT (1) FOR [FWAREHOUSE],
	CONSTRAINT [DF_IO_CONTROL_FBEGTIME] DEFAULT ('-') FOR [FBEGTIME],
	CONSTRAINT [DF_IO_CONTROL_FENDTIME] DEFAULT ('-') FOR [FENDTIME]
GO

ALTER TABLE [dbo].[T_Base_Device] ADD 
	CONSTRAINT [DF_T_Base_Device_F_LockedState] DEFAULT (0) FOR [F_LockedState],
	CONSTRAINT [DF_T_Base_Device_F_DeviceVisual] DEFAULT (0) FOR [F_DeviceVisual],
	CONSTRAINT [DF_T_Base_Device_F_ClientIndex] DEFAULT (0) FOR [F_ClientIndex]
GO

ALTER TABLE [dbo].[T_Base_Manage_Task] ADD 
	CONSTRAINT [DF_T_Base_Manage_Task_FTASKLEVEL] DEFAULT (1) FOR [FTASKLEVEL],
	CONSTRAINT [DF_T_Base_Manage_Task_FWAREHOUSE] DEFAULT (1) FOR [FWAREHOUSE],
	CONSTRAINT [DF_T_Base_Manage_Task_FSTARTSITE] DEFAULT ('-') FOR [FSTARTSITE],
	CONSTRAINT [DF_T_Base_Manage_Task_FENDSITE] DEFAULT ('-') FOR [FENDSITE],
	CONSTRAINT [DF_T_Base_Manage_Task_FIntoStepOK] DEFAULT ('0') FOR [FIntoStepOK]
GO

ALTER TABLE [dbo].[T_Base_Monitor_Task] ADD 
	CONSTRAINT [DF__T_Base_Mo__F_Mon__1273C1CD] DEFAULT (1) FOR [F_MonitorIndex],
	CONSTRAINT [DF__T_Base_Mo__F_Mon__1367E606] DEFAULT (0) FOR [F_MonitorTaskLevel],
	CONSTRAINT [DF_T_Base_Monitor_Task_F_Status] DEFAULT (0) FOR [F_Status],
	CONSTRAINT [DF__T_Base_Mo__F_Dev__145C0A3F] DEFAULT (1) FOR [F_DeviceStateIndex],
	CONSTRAINT [DF__T_Base_Mo__F_Sta__15502E78] DEFAULT ('-') FOR [F_StartTime],
	CONSTRAINT [DF__T_Base_Mo__F_End__164452B1] DEFAULT ('-') FOR [F_EndTime],
	CONSTRAINT [DF__T_Base_Mo__F_Num__173876EA] DEFAULT (0) FOR [F_NumParam1],
	CONSTRAINT [DF__T_Base_Mo__F_Num__182C9B23] DEFAULT (0) FOR [F_NumParam2],
	CONSTRAINT [DF__T_Base_Mo__F_Num__1920BF5C] DEFAULT (0) FOR [F_NumParam3],
	CONSTRAINT [DF__T_Base_Mo__F_Num__1A14E395] DEFAULT (0) FOR [F_NumParam4],
	CONSTRAINT [DF__T_Base_Mo__F_Num__1B0907CE] DEFAULT (0) FOR [F_NumParam5],
	CONSTRAINT [DF__T_Base_Mo__F_Num__1BFD2C07] DEFAULT (0) FOR [F_NumParam6],
	CONSTRAINT [DF__T_Base_Mo__F_Txt__1CF15040] DEFAULT ('-') FOR [F_TxtParam]
GO

ALTER TABLE [dbo].[T_Base_Route_Detail] ADD 
	CONSTRAINT [DF_T_Base_Route_Detail_F_EndNode] DEFAULT ('0') FOR [F_EndNode],
	CONSTRAINT [DF_T_Base_Route_Detail_F_WaitPallet] DEFAULT ('0') FOR [F_WaitPallet]
GO

 CREATE  INDEX [IX_T_ITEMDEVICESTATION] ON [dbo].[T_ITEMDEVICESTATION]([FCODE]) ON [PRIMARY]
GO

ALTER TABLE [dbo].[T_Base_Device] ADD 
	CONSTRAINT [FK_T_Base_Device_T_Base_Device_Kind] FOREIGN KEY 
	(
		[F_DeviceKindIndex]
	) REFERENCES [dbo].[T_Base_Device_Kind] (
		[F_DeviceKindIndex]
	) ON DELETE CASCADE  ON UPDATE CASCADE 
GO

ALTER TABLE [dbo].[T_Base_Route_Detail] ADD 
	CONSTRAINT [FK_T_Base_Route_Detail_T_Base_Route_Kind] FOREIGN KEY 
	(
		[F_RouteKindIndex]
	) REFERENCES [dbo].[T_Base_Route_Kind] (
		[F_RouteKindIndex]
	) ON DELETE CASCADE  ON UPDATE CASCADE 
GO

ALTER TABLE [dbo].[T_ITEMTASKTYPE_RouteKind] ADD 
	CONSTRAINT [FK_T_ITEMTASKTYPE_RouteKind_T_Base_Route_Kind] FOREIGN KEY 
	(
		[F_RouteKindIndex]
	) REFERENCES [dbo].[T_Base_Route_Kind] (
		[F_RouteKindIndex]
	)
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.V_Manage_Task
AS
SELECT FID AS 管理任务唯一索引, F_ManageTaskKindIndex AS 管理任务类型, 
      FTASKTYPE AS 搬运任务类型, FTASKLEVEL AS 优先级, FISRETURN AS 是否返库, 
      FWAREHOUSE AS 仓库索引, FSTARTPOSITION AS 起点, FSTARTSITE AS 起点货位, 
      FENDPOSITION AS 终点, FENDSITE AS 终点货位, FSTATUS AS 任务状态, 
      FBEGTIME AS 开始时间, FENDTIME AS 结束时间
FROM dbo.T_Base_Manage_Task

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.V_Monitor_Task
AS
SELECT F_ManageTaskIndex AS 管理任务唯一索引, 
      F_ManageTaskKindIndex AS 管理任务类型, F_MonitorIndex AS 监控任务索引, 
      F_MonitorTaskLevel AS 任务优先级, F_DeviceIndex AS 设备索引, 
      F_DeviceCommandIndex AS 设备命令, F_DeviceStateIndex AS 设备状态, 
      F_StartTime AS 开始时间, F_EndTime AS 结束时间
FROM dbo.T_Base_Monitor_Task

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

CREATE VIEW dbo.V_DeviceCommand
AS
SELECT dbo.T_Base_Device.F_DeviceIndex, dbo.T_Base_Device.F_DeviceName, 
      dbo.T_Base_Device_Command.F_DeviceCommandIndex, 
      dbo.T_Base_Device_Command.F_DeviceCommandName
FROM dbo.T_Base_Device INNER JOIN
      dbo.T_Base_Device_Command ON 
      dbo.T_Base_Device.F_DeviceKindIndex = dbo.T_Base_Device_Command.F_DeviceKindIndex

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

