【问题标题】:Set column type with a select ... into statement使用 select ... into 语句设置列类型
【发布时间】:2013-06-01 10:15:35
【问题描述】:

我正在尝试使用 SELECT ... INTO 语句创建表。该表已正确创建并填充,但我想更改其中两列的数据类型。

SELECT DISTINCTROW 
    AR_Server_Pre.OrderID, 
    AR_Server_Pre.LineTotal, 
    AR_Server_Pre.[Total payments], 
    AR_Server_Pre.ShipDate, 
    (AR_Server_Pre.LineTotal-nz(AR_Server_Pre.[Total Payments])) AS AmountDue 
INTO AR_Final
FROM AR_Server_Pre
WHERE 
    ((([AR_Server_Pre].[LineTotal]-nz([AR_Server_Pre].[Total Payments]))>0.5) 
    AND 
    ((AR_Server_Pre.ShipDate)<Date()));

我想将货币列类型分配给 LineTotal 和 AmountDue。 AR_Server_Pre 是一个 Select Query,因此“在该表上更改它”的简单解决方案将不起作用。

【问题讨论】:

    标签: sql ms-access ms-access-2003


    【解决方案1】:

    您可以将指定的字段包装在CCur() 函数中,以强制它们为Currency,例如,

    SELECT DISTINCTROW 
        AR_Server_Pre.OrderID, 
        CCur(AR_Server_Pre.LineTotal) AS LineTotal, 
    ...
    

    【讨论】:

    • 太棒了,谢谢。我知道它一定是这样的,但我无法弄清楚确切的格式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-18
    • 1970-01-01
    • 2016-03-20
    • 2017-01-24
    • 1970-01-01
    • 1970-01-01
    • 2012-04-07
    相关资源
    最近更新 更多