单一存储过程在sqlserver 2005中执行所有dml操作 [英] Single store procedure perform all dml operation in sqlserver 2005

查看:111
本文介绍了单一存储过程在sqlserver 2005中执行所有dml操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过sql server 2005中的单个存储过程执行所有dml操作.如何实现此目标?请帮助

I want to perform all dml operation by a single stored procedure in sql server 2005. how could I achieve this? Please Help

推荐答案

唯一可行的方法是使用EXEC,但是使用EXEC的代码将在用户安全权限下运行,因此您将拥有允许访问表和视图等.

通常,这不是一个好习惯,如果您希望编写更少的代码并且需要更少的维护,那么我建议您不要使用存储过程并将SQL嵌入到您的代码中(更快,单一源代码控制点,并且不绑定到特定的供应商).
The only way this is possible is through the use of EXEC, but code using EXEC will run with the users security permissions, so you will have to give access to tables and views etc.

Generally this is not a good practice, if you are looking to write less code and having less to maintain then I would suggest not using stored procedures and embedding SQL in your code (much faster, single source control point, and not bound to a specific vendor).


这不是一个好选择.您会发现很难管理数据.如果要对所有DML操作使用单个存储过程,则可以使用它,但是需要维护一个指示符作为输入参数.每次需要检查参数时,都需要根据该参数执行操作.最好使用各个参数.


--Amit
This will not be the good option. You''ll find much difficulty to manage the data. If you want to use single stored procedure for all the DML operation you can have it but you need to maintain an indicator as input parameter. Every time you need to check the parameter and based upon that you need to perform the operations. Better to go with the individual parameters.


--Amit


这篇关于单一存储过程在sqlserver 2005中执行所有dml操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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