在asp.net和sql server 2005中从多个线程同时调用存储过程 [英] Calling a stored procedure simultaniously from multiple threads in asp.net and sql server 2005

查看:28
本文介绍了在asp.net和sql server 2005中从多个线程同时调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以同时从多个线程调用存储过程?

Is it possible to call a stored procedure from multiple threads simultaneously?

我想知道这在 sql server 2005 中是否可行.SQL server 是如何处理的?

I want to know whether this is possible in sql server 2005. How does SQl server handle this?

它会抛出错误还是会创建存储过程的多个实例并运行它?

Will it throw an error or will it create multiple instance of the stored procedure and run it?

我知道我应该为此使用锁.但我想知道如果我不这样做会发生什么.

I know i should use locks for this. But I want to know what will happen if I don't.

谢谢,西德

推荐答案

是的,这是可能的.

SQL Server 可以很好地处理这个问题 - 这就是数据库所做的,同时处理多个连接.

SQL Server will handle this fine - that's what databases do, handle multiple connections simultaneously.

我不知道您所说的存储过程的多个实例"是什么意思 - 数据库中只有一个 SP 定义并且会被执行.如果需要,它可以由多个线程执行.数据库将为您处理并发.

I don't know what you mean by "multiple instance of the stored procedure" - there is only one definition of a SP in the database and that will get executed. It can be executed by many threads if needed. The database will handle the concurrency for you.

锁的使用取决于应用程序以及您访问数据库的方式(以及您采取的操作的含义 - 它们是否需要原子化/可序列化等).

Use of locks depends on the application and how you access the database (and the meaning of the actions you take - whether they need to be atomic/serializable etc).

这篇关于在asp.net和sql server 2005中从多个线程同时调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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