declare @moduleID uniqueidentifier ,@roleID uniqueidentifier
select top 1 @moduleID = NEWID(), @roleID = [RoleID] from [dbo].[T_ROLES] where [RoleName] = 'Администратор'

if not exists(select * from [dbo].[T_CLIENT_MODULES] where [ModuleType] = 'FIES.Client.ListsClientModule, FIES.Client')
begin
	INSERT INTO [dbo].[T_CLIENT_MODULES] ([ClientModuleID], [ModuleType], [ModuleDescription], [Priority]) SELECT @moduleID, 'FIES.Client.ListsClientModule, FIES.Client', 'Модуль списков', 9
	INSERT INTO [dbo].[T_ROLE_CLIENT_MODULES] ([RoleClientModuleID], [ClientModuleID], [RoleID], [LoadOrder]) SELECT NEWID(), @moduleID, @roleID, 0
end
else
update [dbo].[T_CLIENT_MODULES] set [ModuleDescription] = 'Модуль списков', [Priority] = 9 where [ModuleType] = 'FIES.Client.ListsClientModule, FIES.Client'
GO