34,587
社区成员
发帖
与我相关
我的任务
分享
USE testxx;
GO
CREATE PROC P1
(
@card_type VARCHAR(120)='01'
)
AS
/******************************备份原始表******************************************/
DECLARE @table_no VARCHAR(120);
SELECT @table_no='bak'+FORMAT(GETDATE(),'yyyyMMddHHmmss');
IF OBJECT_ID(@table_no,'U') IS NOT NULL
BEGIN
RAISERROR(N'表名已存在',16,1)
RETURN -1
END
DECLARE @sql NVARCHAR(MAX);
SET @sql='select * into ['+@table_no+'] from t_rm_vip_info';
EXEC (@sql);
/*****************************插入明细数据*******************************************/
---select * from t_rm_vip_info where dbo.f_get_descry_star(residual_amt) >10
---select card_id,dbo.f_get_descry_star(residual_amt) from t_rm_vip_info where dbo.f_get_descry_star(residual_amt) >10
INSERT INTO t_rm_saving_plus_record (branch_no
, card_id
, plus_count
, oper_id
, oper_date
, old_count
, num1
, other1
, residual_amt
, com_flag
, plus_real_count
, real_date
, pay_way)
SELECT '000'
, card_id
, (10-dbo.f_get_descry_star(residual_amt)) AS plus_count
, '1001'
, GETDATE()
, dbo.f_get_descry_star(residual_amt)
, '0'
, '自动清除'
, '0'
, '0'
, (10-dbo.f_get_descry_star(residual_amt))
, NULL
, 'RMB'
FROM t_rm_vip_info
WHERE dbo.f_get_descry_star(residual_amt) >10
AND card_type=@card_type;
/*****************************更改值*******************************************/
UPDATE t_rm_vip_info
SET residual_amt='<:66420.-'
WHERE dbo.f_get_descry_star(residual_amt) >10
AND card_type=@card_type;
CREATE PROC dbo.pro_11
@card_type NVARCHAR(120)
AS
/******************************备份原始表******************************************/
DECLARE @table_no VARCHAR(120);
SELECT @table_no = 'bak' + REPLACE(REPLACE(REPLACE(CONVERT(CHAR(19), GETDATE(), 121), '-', ''), ':', ''), ' ', '');
--select @table_no
DECLARE @sql NVARCHAR(MAX);
SET @sql = 'select * into [' + @table_no + '] from t_rm_vip_info';
EXEC (@sql);
/*****************************插入明细数据*******************************************/
---select * from t_rm_vip_info where dbo.f_get_descry_star(residual_amt) >10
---select card_id,dbo.f_get_descry_star(residual_amt) from t_rm_vip_info where dbo.f_get_descry_star(residual_amt) >10
INSERT INTO t_rm_saving_plus_record
(
branch_no,
card_id,
plus_count,
oper_id,
oper_date,
old_count,
num1,
other1,
residual_amt,
com_flag,
plus_real_count,
real_date,
pay_way
)
SELECT '000',
card_id,
(10 - dbo.f_get_descry_star(residual_amt)) AS plus_count,
'1001',
GETDATE(),
dbo.f_get_descry_star(residual_amt),
'0',
'自动清除',
'0',
'0',
(10 - dbo.f_get_descry_star(residual_amt)),
NULL,
'RMB'
FROM t_rm_vip_info
WHERE dbo.f_get_descry_star(residual_amt) > 10
AND card_type = @card_type;
/*****************************更改值*******************************************/
UPDATE t_rm_vip_info
SET residual_amt = '<:66420.-'
WHERE dbo.f_get_descry_star(residual_amt) > 10
AND card_type = @card_type;
GO