对了,上面的语句有的机子还是不行,改成这样了,把存储过程发上来。
if exists (select * from dbo.sys
objects where id =
object_id(N'[dbo].[DELCars1]') and
OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[DELCars1]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE DELCars1
AS
DECLARE @Row1 smallint
BEGIN TRANSACTION
INSERT INTO CarsSer Select * from cars1 where datediff(day,时间,getdate())>=3
SET @Row1=@@rowcount
IF @@ERROR<>0
BEGIN
ROLLBACK TRANSACTION
RETURN 1
END
Delete from cars1 where datediff(day,时间,getdate())>=3
IF @@ERROR<>0 OR @@rowcount<>@Row1
BEGIN
ROLLBACK TRANSACTION
RETURN 1
END
COMMIT TRANSACTION
RETURN 0
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO