title: SQL Server stored procedure slow in application but fast in SQL Server Management Studio
body: <p>I have a stored procedure on SQL Server 2005. When running in SQL Server Management Studio, it blindingly fast; but when I run it in a C# program through system.data, or run it in some other programs through ODBC or JDBC driver, they all run for ever or give timeout error. I don't have the access to the details of the stored procedure. what could be the possible reason for the performance discrepancy? -it is  SQL Server Management Studio vs .net/ODBC/JDBC. ( I tried same query in C# for .net, R for ODBC and matlab for JDBC driver.) </p>