/*
begin tran
SELECT COUNT(*) FROM PersonelDepartmentsXtab (NOLOCK)
SELECT COUNT(*) FROM PersonelAccess (NOLOCK)
*/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'DepartmentInsertAuto') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  exec dbo.DepartmentInsertAuto
/*
SELECT COUNT(*) FROM PersonelDepartmentsXtab (NOLOCK)
SELECT COUNT(*) FROM PersonelAccess (NOLOCK)
rollback tran
*/
