

if exists (select * from @t6db..AccInformation where cSysID ='aa' and cName ='VersionFlag' and cValue like '8.21%')
 raiserror ('不可以转换T3数据，请先升级至T6！',16,1)
go
--AA 99 VersionFlag 版本标志 text 8.213 8.213 0 0 

IF OBJECT_ID('@t6db..UA_Account_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Account_Ex FROM @t6db..UA_Account_Ex
IF OBJECT_ID('@t6db..UA_Account_sub_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Account_sub_Ex FROM @t6db..UA_Account_sub_Ex
IF OBJECT_ID('@t6db..UA_Auth_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Auth_Ex FROM @t6db..UA_Auth_Ex
IF OBJECT_ID('@t6db..UA_FlowItems_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_FlowItems_Ex FROM @t6db..UA_FlowItems_Ex
IF OBJECT_ID('@t6db..UA_FlowLines_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_FlowLines_Ex FROM @t6db..UA_FlowLines_Ex
IF OBJECT_ID('@t6db..UA_Group_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Group_Ex FROM @t6db..UA_Group_Ex
IF OBJECT_ID('@t6db..UA_HoldAuth_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_HoldAuth_Ex FROM @t6db..UA_HoldAuth_Ex
IF OBJECT_ID('@t6db..UA_Identity_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Identity_Ex FROM @t6db..UA_Identity_Ex
IF OBJECT_ID('@t6db..UA_Log_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Log_Ex FROM @t6db..UA_Log_Ex
IF OBJECT_ID('@t6db..ua_password_Ex') IS NOT NULL
SELECT * INTO @u8db..ua_password_Ex FROM @t6db..ua_password_Ex
IF OBJECT_ID('@t6db..UA_Period_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Period_Ex FROM @t6db..UA_Period_Ex
IF OBJECT_ID('@t6db..UA_Role_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_Role_Ex FROM @t6db..UA_Role_Ex
IF OBJECT_ID('@t6db..UA_User_Ex') IS NOT NULL
SELECT * INTO @u8db..UA_User_Ex FROM @t6db..UA_User_Ex
GO
--创建会计期间临时表，以便后面脚本访问,每次转换时都会新开连接，只需要创建，不需要删除
IF OBJECT_ID('tempdb..#UA_Period') IS NULL
BEGIN
	IF NOT OBJECT_ID('@t6db..UA_Period_EX') IS NULL
	BEGIN
		SELECT * INTO tempdb..#UA_Period FROM @t6db..UA_Period_EX
		UPDATE #UA_Period SET cAcc_ID=@cAcc_ID
	END
END
GO
ALTER TABLE @u8db..CurrentStock ALTER COLUMN cBatch varchar(60) NULL
GO
use @u8db
go
IF  EXISTS (SELECT * FROM sysindexes WHERE id = OBJECT_ID(N'Person') AND name = N'cPersonName')
DROP INDEX Person.cPersonName
GO
