SET LANGUAGE russian
SET IMPLICIT_TRANSACTIONS OFF
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET CONCAT_NULL_YIELDS_NULL ON
SET NUMERIC_ROUNDABORT OFF
SET NOCOUNT OFF
SET LOCK_TIMEOUT -1
SET XACT_ABORT ON
SET ARITHABORT ON
SET CURSOR_CLOSE_ON_COMMIT OFF
SET DATEFIRST 1
SET DATEFORMAT DMY
SET QUOTED_IDENTIFIER ON
GO
UPDATE OBJECT_VALUES
SET VALUE = '0'
Where object in (select link from s_objects where code in ('PROJECT', 'WF_PROJECT'))
  and property in (select link from s_property where code in ('VERSION', 'VERSION_MAJOR', 'VERSION_MINOR', 'VERSION_RELEASE', 'VERSION_FIX'))
GO
IF NOT EXISTS(select * from user_task WHERE SID = USER_SID() )
	INSERT INTO user_task (SID, LINK_TASK)
	SELECT  USER_SID(), LINK FROM S_OBJECTS WHERE CODE = 'SMETA'
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[tmp_dates2]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [tmp_dates2]
GO
EXECUTE dbo.X_CHANGE_USER_TASK 'SMETA'
GO
select * into tmp_dates2 from admin_info
GO
Declare @kassa int, @BB datetime, @BE datetime
Select @kassa = LINK from S_OBJECTS Where CODE = 'SMETA'
SELECT @BB = convert(datetime, '19000101', 112), @BE = convert(datetime, '21100101', 112)
EXECUTE I_SET_ADMIN_DATE @kassa, @BB, @BB, @BE
GO



WHILE @@TRANCOUNT > 0
	raiserror('@@TRANCOUNT>0!!!',11,1)
GO
IF not exists (SELECT * FROM ::fn_listextendedproperty('ID', 'USER', 'dbo', 'Table', 'S_OBJECTS', NULL, NULL))
BEGIN
	declare @newid uniqueidentifier
	set @newid = newid()
	EXEC sp_addextendedproperty 'ID', @newid, 'USER', 'dbo', 'Table', 'S_OBJECTS', NULL, NULL
END
GO

GO
