Chances are that you are hitting on a problem with parameter sniffing.
I suggest reading Slow in the Application, Fast in SSMS? by Erland Sommarskog to get a full understanding of the issue (long article but very good).
More Related Contents:
- sql server 2008 management studio not checking the syntax of my query
- SQL Server 2008: how do I grant privileges to a username?
- Converting Select results into Insert script – SQL Server
- Restrict varchar() column to specific values?
- Insert local .csv data in remote SQL Server via already working connection string
- Syntax combine two stored procedure into one [closed]
- How to delete duplicate rows in SQL Server?
- CROSS JOIN vs INNER JOIN in SQL
- How to cast the DateTime to Time
- How can I schedule a job to run a SQL query daily?
- Reset identity seed after deleting records in SQL Server
- How to avoid the “divide by zero” error in SQL?
- Multiple INSERT statements vs. single INSERT with multiple VALUES
- Real life example, when to use OUTER / CROSS APPLY in SQL
- How to convert an integer (time) to HH:MM:SS::00 in SQL Server 2008?
- What is the order of execution for this SQL statement
- Splitting delimited values in a SQL column into multiple rows
- How to import text files with the same name and schema but different directories into database?
- Split values over multiple rows [duplicate]
- How can I alter this computed column in SQL Server 2008?
- How to get the size of a varchar[n] field in one SQL statement?
- SQL Server: should I use information_schema tables over sys tables?
- Closing connection when using Dapper
- TSQL – How to use GO inside of a BEGIN .. END block?
- SQL take just the numeric values from a varchar
- Cumulative Total in MS Sql server [duplicate]
- How to write a WHERE Clause to find all records in a specific month?
- How to make a view column NOT NULL
- Flattening of a 1 row table into a key-value pair table
- SQL Server equivalent of WM_CONCAT function [duplicate]