Connection Timeout Linked Server - sql-server-2005

I have created a linked server from one SQL Server 2005 to Another 2005. When I run an update query through the SQL Server Management Studio (SSMS), it runs in under a second. If I run the query through a asp webpage it times out. I ran SQL Profiler to see if I noticed anything as well as the Activity Monitor in SSMS and all I found was that a lock was being created (Wait type LOCK_M_U), but I can't find what is locking it. Any help would be appreciated.
Wade

It could be that the user account that you run under in SSMS and from the ASP page have different permissions on the linked server, which could lead to a difference in which query plans it uses when running your update. See this answer to a more generic question about linked server performance.

The issue seems to be with the ADO activeX component, since I used ASP.Net and it worked flawlessly. Oh well.

Related

Can I restore a backup which was on SQL Express to sql server server 2008 without any problems

I am going to do a customer SQL upgrade and they currently have SQL Express and I want to upgrade it to Microsoft SQL server 2008.
Will it be okay to restore the SQL Express backup to Microsoft SQL Server 2008?
First off, the comments seem to mention MySQL. I can see that you edited it to say SQL Express. If it is indeed MS SQL Express then yes, as SMM said it will work.
I have done this a few times before, and it worked just fine. Though rather than a backup/restore I would move the .mdf file.
This is done by detaching the DB from the Express instance and attaching it to the Server 2008 instance; this can be easily done via sqlcmd or the Studio Manager. The steps can vary based on systems(s) setup. As such, I did a google search to see if there existed a step by step guide for this rather than typing a bunch of scenarios as shots in the dark. There are a plethora of them:
I just Googled: move sql express .mdf to sql server 2008
I also found this and it would seem to be a good match for your situation and has good information:
http://www.mipsis.com/help/Moving%20SQL%20Express%20Database%20to%20SQL%20Server.pdf
Let me know how it goes, and if you need specific assistance with the process please follow up.
I have done SQL Express to SQL 2000 and SQL 2005 successfully in the (distant) past. I am sure this will work. I don't remember any specific caveats other than making sure that you don't try to go from a later version of Express to an earlier version of SQL.

Not seeing "Execute stored Procedure" in SQL Server 2016

Is anybody else having an issue when they right click on an SP, and not seeing the option to execute the SP? Only option that I have is to script as execute. I am running SQL Server 2016 express.
Too long for comment!
I suggest that you back up the database now. Full and transaction.
Then check the Compatibility level. Change it back to your previous version of SQL server. Take another back up (to a new file!!).
Now did you upgrade the whole of SQL server or just SSMS? You could just install another earlier version of SSMS and leave the existing server in place and running, test to see if the functionality is all still there with the new (older) SSMS and the old (Ok most recently installed SQL Server).
Microsoft are doing monthly releases of SSMS so it is changing fast - which can mean bugs, but the server should be more stable, so the problem could just be a SSMS issue and your database could be fine.
New patch came out. It works wonderfully now. My issue was resolved. Thanks for the help...

IIS takes longer to run queries than SMSS

I'm completely stumped on this one.
We're running a pretty usual intranet app here, classic ASP frontend and SQL Server 2005 backend.
Occasionally, once/twice a week, a certain stored proc takes ~50x longer to run when I run it in the Management Studio. This slowness lasts the entire day and it inexcplicably goes away the next day.
So essentially what's happening is this: once/twice a week, when I fire up the intranet page that runs the stored procedure and displays the results, it takes roughly 115secs to run.
I then fire up SQL Server Management Studio and run the same query, which this time around takes only 3-4secs to run.
The next day, the intranet page is taking as long as SSMS to run the very same stored procedure, with nothing having been changed in the interim (not to my knowledge anyway).
Other details:
the IIS connects to SQL Server 2005 using Provider=sqloledb as the driver
the slowdown lasts the entire day, regardless of the number of active users
I can replicate the slowness by running the same query from Excel, using the same driver/connection string
I've ran a trace on the SQL server and it turns out that on those particularly slow days, the duration of the stored proc is actually longer when executed via IIS than direct query
As such, I was wondering whether any of you has encountered any similar behaviour before, if you've fond a solution to it and what would your advice be in tackling/solving it?
Thanks for your help,
Please find Trace results in .csv format below:
EventClass,TextData,ApplicationName,CPU,Reads,Writes,Duration (s),ClientProcessID,SPID,StartTime,EndTime
12,exec spStubbornProc,Internet Information Services,"106,016","7,059,999",1,115.80,5476,85,18/04/2013 08:17:15,18/04/2013 08:19:11
12,exec dbo.spStubbornProc,Microsoft SQL Server Management Studio - Query,"3,141","146,051",0,3.40,5876,84,18/04/2013 08:20:45,18/04/2013 08:20:48
12,exec dbo.spStubbornProc,Microsoft SQL Server Management Studio - Query,"2,563","147,387",0,2.93,5876,84,18/04/2013 08:21:04,18/04/2013 08:21:07
12,exec spStubbornProc,Internet Information Services,"103,156","7,083,365",7,118.73,5476,80,18/04/2013 09:39:41,18/04/2013 09:41:40
12,exec dbo.spStubbornProc,Microsoft SQL Server Management Studio - Query,"2,406","175,029",1,2.57,5876,84,18/04/2013 10:08:58,18/04/2013 10:09:01
12,exec spStubbornProc,Internet Information Services,"112,218","7,103,267",7,114.72,5476,75,18/04/2013 14:06:26,18/04/2013 14:08:21
12,exec spStubbornProc,Internet Information Services,"93,515","7,101,229",3,93.60,6092,60,18/04/2013 19:37:02,18/04/2013 19:38:35
12,exec spStubbornProc,Internet Information Services,"2,500","148,775",1,3.42,5160,75,19/04/2013 09:16:01,19/04/2013 09:16:04

See queries that hit SQL

Is there a way using sql 2008 Management Studio to look at the queries that hit the server? I'm trying to debug a program and I get messages like "Incorrect syntax near the keyword 'AND'". Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.
Any help is appreciated!
There is a tool called Profiler that will tell you all information that you'll need. MSDN: http://msdn.microsoft.com/en-us/library/ms187929.aspx
I'm not aware of any method to do this using SQL Server Management Studio, but if you installed SSMS then you probably also installed the SQL Profiler. If you fire that up and run the TSQL_SPs profiler template, you can see every statement that's hitting the database.
Since the queries are being dynamically generated it's a hassle to figure out what is going to the server.
Why not just put the query that's generated into a message box, or print it to the console, or webpage, etc. ??
Trying to catch it at the DB server seems to be the long-way-around to debugging some simple ad-hoc queries.
Go to Management...Activity Monitor in the object explorer.
It's not live though, you will have to refresh it manually.
start up profiler from SSMS (Tools-->SQL Server Profiler), run a trace and select the T-SQL events
One option is to use SQL Server Profiler to run a trace. However, in some shops SQL Server permissions are set so only DBAs can run traces.
If you don't have sufficient rights to run a trace, then another option is to view the network traffic between the application that generates the SQL and box SQL Server is running on. WireShark works great for that.

How can I monitor the executed sql statements on a SQL Server 2005

In a project of mine the SQL statements that are executed against a SQL Server are failing for some unknown reason. Some of the code is already used in production so debugging it is not an easy task. Therefore I need a way to see in the database itself what SQL statements are used, as the statements are generated at runtime by the project and could be flawed when certain conditions are met.
I therefore considered the possibility to monitor the incoming statements and check myself if I see any flaws.
The database is running on a SQL Server 2005, and I use SQL server management studio express as primary tool to manipulate the database. So my question is, what is the best way to do this?
Seeing how you use the Management Studio Express, I will assume you don't have access to the MSSQL 2005 client tools. If you do, install those, because it includes the SQL profiler which does exactly what you want (and more!). For more info about that one, see msdn.
I found this a while ago, because I was thinking about the exact same thing. I have access to the client tools myself, so I don't really need to yet, but that access is not unlimited (it's through my current job). If you try it out, let me know if it works ;-)
Best way is to fire up profiler, start a trace, save the trace and then rerun the statements