存储过程和SQL之间的确切区别是什么 [英] What is the exact difference between stored procedure and SQL

查看:99
本文介绍了存储过程和SQL之间的确切区别是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请用示例解释我,我在很多网站上都有所帮助,但我无法得到确切的区别。

Please do explain me with example, i refereed to many websites but i am unable get the exact difference.

推荐答案

SQL是一种可以让你表达查询的语言。存储过程是包含SQL的数据库实体,允许通过执行存储过程来执行SQL。想象SQL就像c#和Stored Procs那样代码中的方法。



但是你可能真的想要问动态SQL和存储过程之间的区别。动态SQL是指您在运行时创建SQL并对数据库引擎执行它,而对于存储过程,SQL固定为SP中的任何内容。
SQL is a language that lets you express queries. A stored procedure is a database entity that contains SQL and allows the SQL to be executed by executing the Stored Procedure. Think of SQL like c# and Stored Procs like methods in your code.

However you probably really meant to ask the difference between dynamic SQL and stored procedures. Dynamic SQL is when you create SQL on the fly and execute it against the database engine, whereas with a stored proc the SQL is fixed to whatever is in the SP.


存储过程就像函数一样打电话,



您可以在工作中使用n个查询..您只需定义(或)存储在表单中..



例如..以下只是一个想法,而不是确切的语法..



stored procedure is like function call,

there are n number of queries u may use in your work.. You just define (or) stored in a form..

For example .. The following is just a idea,not exact syntax..

1.select * from tbl_table
2.select a.a_id,b.name from tbl_a as a inner join tbl_b as  b on a.a_id=b.a_id
3.select a_id from tbl_a where a_id=@a_id



以上是查询..



每次都写你的时间

查询c#中的表格






The above are query..

In ur wrk u write each time
Forms in c# by Query


form-1
{
string query="select * from tbl_table" ;
--------
----
---
string query="select * from tbl_table" ;

---------
------
string query="select a.a_id,b.name from tbl_a as a inner join tbl_b as  b on a.a_id=b.a_id" ;
----
}
form-2
{


---------
------
string query="select a.a_id,b.name from tbl_a as a inner join tbl_b as  b on a.a_id=b.a_id" ;
}





所以我们必须使用我们刚才定义的存储过程



value = 1从tbl_table中选择*



value = 2选择a.a_id,b.name从tbl_a作为内部联接tbl_b作为b在a.a_id = b.a_id

value = 3是从tbl_a中选择a_id,其中a_id = @ a_id





现在我们只需在我们需要的地方调用



存储过程中的c#表格






So we have to go with stored procedure we just define

value=1 is select * from tbl_table

value=2 is select a.a_id,b.name from tbl_a as a inner join tbl_b as b on a.a_id=b.a_id
value=3 is select a_id from tbl_a where a_id=@a_id


Now we just call defined at wherever we need

Forms in c# by Stored Procedure


form-1
{
commandType=storedprocedure;
value=1
.........
value=2
....
value=3
.....
value=1..

}
Form-2

{
value=3
.....
}





对于每个表格,你可能会厌倦写查询,无论你需要从存储的程序中取出由你...





它不是一个完美的语法只是一个想法语法不正确



For each form u may tired on writing query ,Wherever u need just take from the procedure which was stored by u...


Its not a perfect syntax just an Idea not exact syntax


这篇关于存储过程和SQL之间的确切区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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