use wuhan_yuyuan SELECT * FROM TMemberTransHist SELECT A.FId AS ID, A.FMemId AS 会员ID, CONVERT(VARCHAR,FTime,120) as 时间 , CASE FBizType WHEN 'Item' THEN '消费项目' WHEN 'Goods' THEN '购买产品' WHEN 'CardSale' THEN '储值卡开卡' WHEN 'CardRchg' THEN '储值卡充值' WHEN 'CourseSale' THEN '疗程销售' WHEN 'Repay' THEN '还款' ELSE FBizType END AS 业务类别, FTransNo as 单号, FContentText AS 内容, wuhan_yuyuan.dbo.FNNumToStr(FQuantity) AS 数量, wuhan_yuyuan.dbo.FNNumToStr(FAmount) AS 金额, FPayment AS 支付方式, FEmployee AS 员工 INTO TImpMemberTransHist FROM wuhan_yuyuan..TMemberTransHist AS A WHERE FMemId IN(SELECT FMemId FROM wuhan_yuyuan..TMember WHERE FDeleted = 0) SELECT FMemId AS 会员ID, FMemNO AS 会员编号, FName AS 姓名,FMobilePhone AS 手机, CONVERT(VARCHAR,FCreateDate,23) as 创建日期 , FBirthdayType AS 生日类型, ISNULL(CONVERT(VARCHAR,FBirthday,23),'') AS 生日, dbo.FNNumToStr( FPoint) as 积分,FMemo AS 会员备注 INTO TImpMember FROM TMember WHERE FDeleted = 0 SELECT A.FCardId AS 储值卡Id,A.FCardNo AS 储值卡号,T.FNo AS 卡类别编号,T.FName AS 卡类别名称,FMemId AS 会员ID, CASE WHEN A.FState = 4 THEN '停用' WHEN A.FState = 32 THEN '挂失' ELSE '正常' END AS 状态, CONVERT(VARCHAR,A.FCreateDate,23) as 开卡日期 , CONVERT(VARCHAR,A.FExpiredDate,23) as 有效日期 , FMemo AS 卡备注 INTO TImpMemberCard FROM TMemberCard AS A,TMemberCardType AS T WHERE A.FTypeId = T.FId AND A.FDeleted = 0 SELECT A.FCardId AS 储值卡Id,T.FName AS 账户名称,dbo.FNNumToStr(A.FBalance) AS 余额, dbo.FNNumToStr(A.FArrear) AS 欠款 INTO TImpMemberCardAccount FROM TMemberCardAccount AS A,TPayAccount AS T WHERE A.FCardId IN(SELECT FCardId FROM TMemberCard WHERE FDeleted = 0) AND T.FId = A.FAcctId AND( A.FBalance > 0 OR A.FArrear > 0 ) SELECT * FROM TMemberCourse SELECT A.FId AS ID, A.FMemId AS 会员ID, C.FName AS 疗程名称, I.FName AS 项目名称, dbo.FNNumToStr(A.FPurTimes )AS 购买次数, dbo.FNNumToStr(A.FRemainPurTimes) AS 剩余购买次数, dbo.FNNumToStr(A.FFreeTimes) AS 赠送次数, dbo.FNNumToStr(A.FRemainFreeTimes) AS 剩余赠送次数, dbo.FNNumToStr(A.FPurAmount) AS 购买金额, dbo.FNNumToStr(A.FRemainPurAmount) AS 剩余购买金额, dbo.FNNumToStr(A.FFreeAmount) 赠送金额, dbo.FNNumToStr(A.FRemainFreeAmount) AS 剩余赠送金额, CONVERT(VARCHAR,A.FPurchaseDate,23) as 购买日期 , CONVERT(VARCHAR,A.FExpiredDate,23) as 有效日期 , A.FMemo AS 备注 INTO TImpMemberCourse FROM TMemberCourse AS A,TCourse AS C,TItem AS I WHERE A.FItemId = I.FId AND A.FCourseId = C.FId AND A.FDeleted = 0 SELECT * FROM TMemberArrear WHERE FRemainArrear > 0 use YuYuan SELECT * INTO TImpMember FROM WuHan_YuYuan..TImpMember SELECT * INTO TImpMemberCard FROM WuHan_YuYuan..TImpMemberCard SELECT * INTO TImpMemberCardAccount FROM WuHan_YuYuan..TImpMemberCardAccount SELECT * INTO TImpMemberTransHist FROM WuHan_YuYuan..TImpMemberTransHist SELECT * INTO TImpMemberCourse FROM WuHan_YuYuan..TImpMemberCourse create database YuYuan SELECT * FROM TImpMemberCourse