我输入了一些包含日期列的日期,日期格式不正确,现在如果我再次输入它们,将需要几个月的时间来修复,例如,如果我可以通过一些触发器来修复它的话。数据中输入的日期是 2012 年 5 月 9 日,但实际日期是 2012 年 9 月 5 日。任何想法????
我刚刚做了一个触发器,它安全吗?我希望它只影响一行,而不是全部,我在逻辑上是否正确?
GO
ALTER TRIGGER [dbo].[OnReceiptUpdate]
ON [dbo].[paymentReceipt]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
Declare @correctdate VARCHAR(19);
Declare @receiptNo VARCHAR(50);
DECLARE @customerID NCHAR(50)
SET @customerID= (SELECT customerID FROM inserted)
set @correctdate = (SELECT CONVERT(VARCHAR(19),paymentDate,103) FROM inserted)
set @receiptNo = (SELECT receiptNo FROM inserted)
BEGIN
UPDATE Paymentreceipt
SET paymentDate = @correctdate
WHERE customerID = @customerID and receiptNo=@receiptNo
END
END'