插入临时表时的信用/借记格式

时间:2013-08-30 10:30:12

标签: sql sql-server-2008 tsql

说我有一个像这样的临时表:

create table #temptable
    (
        RecordId int,
        Balance money NOT NULL,
    )

我现在正在使用从仅传递客户参考的存储过程中获取的数据填充此临时表。

Insert into #temptable 
exec getstatementhistory @cust_ref

我现在想要使用#temptable中存储的信息对不同的表进行一些更新/插入。我有一个问题,我希望所有借记都存储在#temptable103.85,所有积分都存储在#temptable-103.85

我遇到的问题是,存储过程会颠倒此约定,因此借记的格式与-103.85类似,并且这样的信用103.85

我需要的是在INSERT INTO #temptable中指定以反转平衡惯例。

如果从SP传递-103.85,请将其作为#temptable存储在103.85中,反之亦然。

任何人都可以建议一种更改我的插入语句的方法来控制临时表中Balance字段的信用/借记格式。

1 个答案:

答案 0 :(得分:0)

Insert into #temptable 
exec getstatementhistory @cust_ref

--After the Insert, update the contents to reverse the format

Update #temptable
set Balance = Balance*-1