if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EmployeeTerritories_Insert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    drop procedure [dbo].[EmployeeTerritories_Insert]
GO
------------------------------------
-- 功能描述：增加一条记录 
-- 所属表格：EmployeeTerritories[ ]
-- 作者名称：
-- 创建日期：
-- 修改日期：
 /*
 -- 测试代码 --
 -- 参数设置 
DECLARE @EmployeeID int -- 雇员ID
    SET @EmployeeID = 
DECLARE @TerritoryID nvarchar(20) -- 领域ID
    SET @TerritoryID =  ' '
 -- 调用存储过程 
 exec [EmployeeTerritories_Insert] @EmployeeID,@TerritoryID
 */
------------------------------------
CREATE PROCEDURE [EmployeeTerritories_Insert] (
@EmployeeID   int = NULL,           -- 雇员ID
@TerritoryID  nvarchar(20) = NULL   -- 领域ID

)
AS
INSERT INTO EmployeeTerritories(
		 
)VALUES( 
		
)
SELECT @ID = SCOPE_IDENTITY() -- 返回新加记录的唯一标识
GO


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EmployeeTerritories_Edit]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[EmployeeTerritories_Edit]
GO
------------------------------------
-- 功能描述：修改一条记录 
-- 所属表格：EmployeeTerritories[]
-- 作者名称：
-- 创建日期：
-- 修改日期：
 /* -- 测试代码 --
 -- 参数设置 
DECLARE @EmployeeID int -- 雇员ID
    SET @EmployeeID = 
DECLARE @TerritoryID nvarchar(20) -- 领域ID
    SET @TerritoryID =  ' '
 -- 调用存储过程 
 exec [EmployeeTerritories_Edit] @EmployeeID,@TerritoryID 
 */
------------------------------------
CREATE PROCEDURE [EmployeeTerritories_Edit]
@EmployeeID   int = NULL,           -- 雇员ID
@TerritoryID  nvarchar(20) = NULL   -- 领域ID

AS 
UPDATE EmployeeTerritories SET 
	
WHERE 
	 [EmployeeID] = @EmployeeID, [TerritoryID] = @TerritoryID
GO


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EmployeeTerritories_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[EmployeeTerritories_Delete]
GO
------------------------------------
-- 功能描述：删除一条记录 
-- 作者名称：
-- 创建日期：
-- 修改日期：
 /*
 -- 测试代码 --
 -- 参数设置 
 -- 调用存储过程 
DECLARE @ID int
    set @ID=0
 exec [EmployeeTerritories_Delete] @ID
 */
------------------------------------
CREATE PROCEDURE [EmployeeTerritories_Delete]
	@EmployeeID int --待删除的主键
AS 
   
	    DELETE FROM [EmployeeTerritories]	    WHERE EmployeeID = @EmployeeID 
     
     
GO   
     


