今天又碰到了新问题,其实主要是忘记了具体的语法。
1、使用T-SQL语句来创建触发器
基本语句为﹕
create trigger trigger_name
on {table_name | view_name}
{for | After | Instead of } [ insert, update,delete ]
as
sql_statement
顺便补充一下关于触发器的其他语句
删除触发器:
drop trigger trigger_name
修改触发器:
alter trigger trigger_name
on {table_name | view_name}
{for | After | Instead of }
[ insert, update,delete ]
as
sql_statement
查看数据库已有触发器:
use jxcSoftware go select * from sysobjects where xtype='TR'
查看单个触发器 :
exec sp_helptext '触发器名'
2、参数化的sql语句中,like 和 in 的正确用法
string sql=" select * from tableA where FieldA like '%' + @FieldA +'%' ";
string sql="exec('select * from tableA where FieldB in (' + @FieldB +')') ";