寻找触发器来更改插入字符串? [英] Looking for a Trigger to change inserting strings?

查看:70
本文介绍了寻找触发器来更改插入字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MSSQL Server 2008数据库.
我的数据库中有一些表,如下所示:
table1,table2,table3,....
每个表都有一个NVARCHAR(50)字段(Name)
现在,我想更改每个sql查询在此字段中插入的字符串
例如:
我们有一个查询要在Name字段中插入示例文本".
我想使用SQL触发器将其更改为样本名称"

sql触发器是否可能?如果是这样,如何?我在T-SQL中很幼稚
是否可以使用SQL Server更好的方法?

I have an MSSQL Server 2008 Database.
There are some tables in my Database like below :
table1, table2, table3, ....
each table has a NVARCHAR(50) field (Name)
Now, I wanna change the strings that each sql query inserts in this field
e.g :
We have a query that wanna insert "Sample Text" in Name field.
I wanna change it to "Sample Name" with a SQL Trigger

Is it Possible with sql triggers ? if so, How? I''m naive in T-SQL
Is there a better way to do it with SQL Server ?

推荐答案

是-触发器可以做到这一点...

如果客户端正在使用存储过程与DB通信,则只需更改SP!如果他们不使用SP,那么这只是很多痛苦的开始

看看触发器简介 [
Yes - Triggers can do this ...

If the clients are talking to the DB with stored procedures, just changed the SP! If they''re not using SPs, then this is only the start of a lot of pain

Have a look at An Introduction to Triggers[^]

On inserts, the triggers get a table called inserted - just modify that table as you want



检查是否有相同的问题
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=152059 [ ^ ]
最好的问候
米特瓦里(M.Mitwalli)
Hi ,
Check this it has same problem
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=152059[^]
Best Regards
M.Mitwalli


这篇关于寻找触发器来更改插入字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆