gpt4 book ai didi

sql - INSERT INTO 语句中的大小写

转载 作者:行者123 更新时间:2023-12-04 16:31:02 25 4
gpt4 key购买 nike

我试图在未提供 ActionReq 时将此存储过程的 ActionReq 列设置为 Expiration + AdvancedCancel 的值。 ActionReq 和 Expiration 是日期时间,AdvancedCancel 是一个整数。我该怎么做?我的 SQL 技能非常基础。

ALTER PROCEDURE [dbo].[insertIntoGrid] 
@Vendor nvarchar(max),
@Product nvarchar(max),
@Type nvarchar(max),
@AccountCode nvarchar(max),
@2016AccCode nvarchar(max),
@BusinessUnit nvarchar(max),
@Group nvarchar(max),
@TIAYTD nvarchar(max),
@ContractPeriod nvarchar(max),
@RenewPeriod nvarchar(max),
@Expiration datetime,
@AdvancedCancel nvarchar(max),
@ActionReq datetime,
@Notes nvarchar(max),
@Division nvarchar(max)
AS
BEGIN
SET NOCOUNT ON;

-- Insert statements for procedure here
INSERT INTO TestRedo3(Vendor, [Product/Service], [Type], AccountCode,
[2016AccCode], BusinessUnit, [Group], TIAYTD,
ContractPeriod, RenewPeriod, Expiration, AdvancedCancel,
case [ActionReq] is null THEN dateadd(day, @AdvancedCancel, @Expiration)
else ActionReq
end as ActionReq, Notes, Division)
VALUES (@Vendor, @Product, @Type, @AccountCode,
@2016AccCode, @BusinessUnit, @Group, @TIAYTD,
@ContractPeriod, @RenewPeriod, @Expiration, @AdvancedCancel,
@ActionReq, @Notes, @Division)
END

最佳答案

您需要将插入内容更改为类似这样的内容。我不完全确定您要做什么,但这应该很接近。

INSERT INTO TestRedo3
(
Vendor,
[Product/Service],
[Type],
AccountCode,
[2016AccCode],
BusinessUnit,
[Group],
TIAYTD,
ContractPeriod,
RenewPeriod,
Expiration,
AdvancedCancel,
ActionReq,
Notes,
Division
)
select
@Vendor,
@Product,
@Type,
@AccountCode,
@2016AccCode,
@BusinessUnit,
@Group,
@TIAYTD,
@ContractPeriod,
@RenewPeriod,
@Expiration,
@AdvancedCancel,
case when @ActionReq is null THEN dateadd(day, @AdvancedCancel, @Expiration)
else @ActionReq
end,
@Notes,
@Division

关于sql - INSERT INTO 语句中的大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40426671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com