mysql创建触发器之前检查是否存在不存在再创建,存在就不创建的sql语句是什么
CREATETRIGGERaaaIFNOTEXISTSAFTERINSERTONpppFOREACHROWBEGININSERTINTObbb(tableName,idC...
CREATE
TRIGGER aaa IF NOT EXISTS AFTER INSERT ON ppp
FOR EACH ROW BEGIN
INSERT INTO bbb (tableName,idColumn,dataRecordId,recordType,recordTime) VALUES ("ppp","aa",NEW.aa,1,NOW());
END;
这么写有错啊 展开
TRIGGER aaa IF NOT EXISTS AFTER INSERT ON ppp
FOR EACH ROW BEGIN
INSERT INTO bbb (tableName,idColumn,dataRecordId,recordType,recordTime) VALUES ("ppp","aa",NEW.aa,1,NOW());
END;
这么写有错啊 展开
1个回答
推荐于2018-04-04
展开全部
-- 判断要创建的存储过程名是否存在
if exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[存储过程名]') and OBJECTPROPERTY(id, N'IsProcedure')= 1)
-- 删除存储过程
drop procedure [dbo].[存储过程名]
GO
if exists (select * from dbo.sysobjects where id =object_id(N'[dbo].[存储过程名]') and OBJECTPROPERTY(id, N'IsProcedure')= 1)
-- 删除存储过程
drop procedure [dbo].[存储过程名]
GO
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询