我在哪里可以使用proc,函数或单行查询 [英] where can i use a proc, function or a single line query

查看:88
本文介绍了我在哪里可以使用proc,函数或单行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我问一个简单的问题......我在哪里可以使用proc / a fn /单行查询?

Hello im asking a simple question... where can i use a proc/ a fn/ single line query??

推荐答案

[我假设你的意思是存储Proc的程序,fn的功能]

请参阅此链接。

什么时候应该使用存储过程? [ ^ ]



它表明。

[I assume you mean Stored Procedure by Proc,Function by fn]
Refer to this link.
When should you use stored procedures?[^]

It states that.
引用:

查看存储过程的一种方法是作为数据库的接口。客户端调用存储过程并且不担心实现。只要签名没有改变,DBA就可以自由地修改底层架构而不会影响客户端。



当你进行功能计算时可以使用存储过程'可以在声明性SQL中完成,最好保留在数据库中。



如果您不担心多个数据库平台并且永远不会迁移,请使用存储过程。

One way to look at stored procedures is as an interface for your database. Clients call the stored procedure and don't worry about the implementation. As long as the signature doesn't change, the DBA is free to modify the underlying schema without affecting clients.

Use stored procedures when you have functional computations that can't be done in declarative SQL and are best left in the database.

Use stored procedures if you aren't worried about multiple database platforms and will never, ever migrate.



使用存储过程的优点: [在sql server中使用存储过程有什么好处 [ ^ ]]



-存储过程允许模块化编程。



您可以创建一次程序,将其存储在数据库中,并在程序中多次调用它。



-Stored Procedure允许更快的执行。



如果操作需要重复执行大量SQL代码,则存储过程可以更快。它们在首次执行时被解析和优化,并且存储过程的编译版本保留在内存高速缓存中供以后使用。这意味着存储过程不需要在每次使用时重新分析和重新优化,从而导致执行时间快得多。



-存储过程可以减少网络流量。



需要数百行Transact-SQL代码的操作可以通过执行过程中代码的单个语句来执行,而不是通过发送数百行网络代码。



-存储过程为您的数据提供更好的安全性



功能用于完成重复任务时,例如,如果你想找到两个数字之和而不是make函数,它将返回两个数字的总和并将值传递给该函数。所以每次你都不会必须为同一任务编写代码。



功能 - 完整的C#教程 [ ^ ]



查询用于执行与database.Eg相关的操作从数据库中获取数据,更新详细信息,插入新记录等。



结构化查询语言[SQL] [ ^ ]



问候......:笑:


Advantages of using stored procedures:[ what are the advantages of using stored procedures in sql server[^]]

-Stored procedure allows modular programming.

You can create the procedure once, store it in the database, and call it any number of times in your program.

-Stored Procedure allows faster execution.

If the operation requires a large amount of SQL code is performed repetitively, stored procedures can be faster. They are parsed and optimized when they are first executed, and a compiled version of the stored procedure remains in memory cache for later use. This means the stored procedure does not need to be reparsed and reoptimized with each use resulting in much faster execution times.

-Stored Procedure can reduce network traffic.

An operation requiring hundreds of lines of Transact-SQL code can be performed through a single statement that executes the code in a procedure, rather than by sending hundreds of lines of code over the network.

-Stored procedures provide better security to your data

Functions are used when the repetitive task is to be done,for example,if you want to find sum of two numbers than make function that will return sum of two numbers and pass the values to that function.So each time you wont have to write code for the same task.

Functions- The complete C# Tutorial[^]

Query is used to perform actions related to database.E.g. Fetch data from database,Update details,insert new records etc.

Structured Query Language[SQL][^]

Regards..:laugh:


这篇关于我在哪里可以使用proc,函数或单行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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