You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
sql-tools/Import/颜艺/阿健2.sql

196 lines
6.8 KiB

DELETE TPayAccount WHERE FId != 0
INSERT TPayAccount(FId,
FNo,
FName,
FDescription,
FIsAccount,
FEnabled,
FOrder,
FAllowEdit)
SELECT FId,
FNo,
FName,
FDescription,
FIsAccount,
FEnabled,
FOrder,
FAllowEdit
FROM db108.ZiBo_YanYi.dbo.TPayAccount
WHERE FId > 0
SELECT * FROM db108.ZiBo_YanYi.dbo.TEmployee WHERE FNo = '1006'
AND FId IN
(
SELECT FEmpId FROM db108.ZiBo_YanYi.dbo.TEmployeeSub WHERE FCompId = 5146190082460629410
)
SELECT name + ',' FROM syscolumns WHERE id = object_id('TMember')
SELECT * FROM db108.ZiBo_YanYi.dbo.TMember WHERE FChargeEmpId = 5456136924168793655
WHERE FCompId = 5146190082460629410
IF OBJECT_ID('PImportTable') IS NOT NULL
DROP PROC PImportTable
GO
CREATE PROC PImportTable
(
@Source VARCHAR(200),
@Target VARCHAR(200),
@Where VARCHAR(8000)
)
AS
BEGIN
DECLARE @Columns VARCHAR(8000)
-- SELECT @Source = 'db108.ZiBo_YanYi.dbo.TMember'
-- SELECT @Target = 'TMember'
IF @Source = @Target
BEGIN
RAISERROR ('²»ÄÜÏàͬ',16,1)
RETURN
END
SELECT @Columns = ''
SELECT @Columns = @Columns + name + ',' FROM syscolumns WHERE id = object_id(@Target)
AND colstat != 4
AND xtype != 189
IF @@ROWCOUNT = 0
BEGIN
SELECT @Columns = ''
SELECT @Columns = @Columns + name + ',' FROM syscolumns WHERE id = object_id(@Source)
AND colstat != 4
AND xtype != 189
END
SELECT @Columns = LEFT(@Columns,LEN(@Columns) - 1)
DECLARE @Sql VARCHAR(8000)
SELECT @Sql = 'INSERT ' + @Target + '(' + @Columns + ')
SELECT ' + @Columns + ' FROM ' + @Source
+ ' WHERE 1=1 '
IF ISNULL(@Where,'') != ''
BEGIN
SELECT @Sql = @Sql + ' ' + @Where
END
PRINT @Sql
EXEC (@Sql)
END
SELECT * FROM syscolumns WHERE id = object_id('TCourse')
PImportTable 'db108.ZiBo_YanYi.dbo.TCourse','TCourse',' AND FId != 0'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMember','TMember',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCard','TMemberCard',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCardAccount','TMemberCardAccount',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCardAcctHist','TMemberCardAcctHist',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberTransHist','TMemberTransHist',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCourse','TMemberCourse',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCourseHist','TMemberCourseHist',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberArrear','TMemberArrear',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberPhoto','TMemberPhoto',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberPointHist','TMemberPointHist',' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMember_Export2)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMember','TMember',
' AND FMemId IN(SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMemberCard WHERE FCompId = 5146190082460629410
UNION ALL SELECT FMemId FROM db108.ZiBo_YanYi.dbo.TMemberCourse WHERE FCompId = 5146190082460629410 )'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCard','TMemberCard',' AND FCompId = 5146190082460629410 AND FMemId > 0'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCardAccount','TMemberCardAccount',' AND FCardId IN(SELECT FCardId FROM TMemberCard)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCardAcctHist','TMemberCardAcctHist',' AND FCardId IN(SELECT FCardId FROM TMemberCard)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberTransHist','TMemberTransHist',' AND FMemId IN(SELECT FMemId FROM TMember)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCourse','TMemberCourse',' AND FCompId = 5146190082460629410'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberCourseHist','TMemberCourseHist',' AND FMemCourseId IN(SELECT FId FROM TMemberCourse)'
DELETE TMemberArrear
SELECT * FROM TMemberArrear
SELECT * FROM TMember WHERE FMemId = 6586155360472999377
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberArrear','TMemberArrear',' AND FMemId IN(SELECT FMemId FROM TMember) AND FCompId = 5146190082460629410'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberPhoto','TMemberPhoto',' AND FMemId IN(SELECT FMemId FROM TMember)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberPointHist','TMemberPointHist',' AND FMemId IN(SELECT FMemId FROM TMember)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberMerge','TMemberMerge',' AND FSourceMemId IN(SELECT FMemId FROM TMember) OR FTargetMemId IN(SELECT FMemId FROM TMember)'
EXEC PImportTable 'db108.ZiBo_YanYi.dbo.TMemberMergeDetail','TMemberMergeDetail',' AND FSourceMemId IN(SELECT FMemId FROM TMember) OR FTargetMemId IN(SELECT FMemId FROM TMember)'
DELETE TMemberPointHist
DELETE TMemberPhoto
DELETE TMemberCourseHist
DELETE TMemberArrear
DELETE TMemberTransHist
DELETE TMemberCardAcctHist
DELETE TMemberCardAccount
DELETE TMemberCourse
DELETE TMemberCard WHERE FMemId > 99
DELETE TMember WHERE FMemId > 99
SELECT * FROM sysobjects WHERE name LIKE '%Member%'
AND type = 'U'
UPDATE TMember SET FState = 1 WHERE FState = 4
UPDATE TMemberCARD SET FState = 1 WHERE FState = 4
UPDATE TMemberCourse SET FState = 1 WHERE FState = 4
UPDATE TMemberCard SET FState = 3 WHERE FMemID = 5051759679318127977
UPDATE TMember SET FState = 3 WHERE FMemID = 5051759679318127977
UPDATE TMemberCard
SET FState = 3 WHERE FMemId IN(SELECT FSourceMemId FROM TMemberMerge)
UPDATE TMember SET FMemo = REPLACE(FMemo,'[¶þµêµÄ»áÔ±¿¨£¬ÒÑת]','')
UPDATE TMemberCARD SET FMemo = REPLACE(FMemo,'[¶þµêµÄ»áÔ±¿¨£¬ÒÑת]','')
UPDATE TMemberCourse SET FMemo = REPLACE(FMemo,'[¶þµêµÄ»áÔ±¿¨£¬ÒÑת]','')
SELECT * FROM TMember WHERE FCompId != 5146190082460629410
UPDATE TMemberTransHist SET FCompId = 1 WHERE FCompId != 1
UPDATE TMember SET FCompId = 1 WHERE FCompId != 1
UPDATE TMemberCard SET FCompId = 1 WHERE FCompId != 1
UPDATE TMemberCourse SET FCompId = 1 WHERE FCompId != 1
UPDATE TMemberCardAcctHist SET FCompId = 1 WHERE FCompId != 1
UPDATE TMemberCourseHist SET FCompId = 1 WHERE FCompId != 1
UPDATE TMemberPointHist SET FCompId = 1 WHERE FCompId = 5146190082460629410
SELECT * FROM TBizLog
SELECT * FROM TCompany
DELETE TCompany WHERE FId = 5146190082460629410
UPDATE TCompany SET FDeleted = 1 WHERE FId != 1
UPDATE TCompany SET FAddress = ''
DELETE TCompany WHERE FId > 1
PInitLunarData 1999
PClearMemberData