Weird Timeout In CLR Stored Procedures That Use FtpWebRequest / Response....
Jan 14, 2007
Hi all,
This is a problem for that I lost a weekend to reach to this conclusions:
Here is the scenario:
I need a file downloaded from a FTP server on my SQL 2005 DB Server to process it in several ways. This file is tens of MBs (let's say 50MB). I set up a CLR stored procedure to bring it locally on the machine.
Inside this procedure, call it getFtpFile, I use the FtpWebRequest to issue the commands I need to the FTP server (get the file size and download the file). For reading and writing I use a StreamReader sr and a StreamWriter. sw
I read the remote file in block with:
sr.ReadBlock(buf, 0, blockSizeBytes);
Everything work file until the last block that, most probably will not be of size blockSizeBytes, but smaller. So, what happens is that when I read this last block there is an exception raised from the call saying:
The underlying connection was closed: An unexpected error occurred on a receive.
This happens only if:
-> the code runs inside SQL (calling the SP) (it runs perfect on normal tet environment where I have another executable and call the getFtpFile method in the CLR dll);
-> 100 seconds (100000 miliseconds) (exactly) have passed (small files do not experiencing this problem)
I thought the reader writer scheme is not perfect and implemented again with a simple FileStream.WriteByte(response.GetResponseStream().Read());
This approach, even if very slow, still has the problem after 100 seconds, in a CLR SQL environment, when it reads the at the last character.
I have used all the combinations of KeepAlive and response.Closose(). Problems still there.
Conclusion: There must be a 100 seconds timeout that immediately after my last byte has been received, closes the connection and the stream of the response crashes during this last call.
is there a way to set timeout in a stored procedure?? I'm running a stored procedure but 10% of the time it will time out and when I say retry it works just fine. I'm wondering if I set the timeout large enough it won't run into that error. I'd like to know what would be the best way to avoid it AND how to set timeout in stored procedures..
I've been researching this problem for weeks and I haven't gotten very far with it so I was hoping to get some help here.
Here's the error information we get: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
This particular error comes from a .net application, but we've seen similar "query timeout errors" from a vb6 application roughly 6 months ago.
Here are the facts we've narrowed down:
1) The timeout happens at seemingly random times (very sporadic). 2) It's currently only happening on a few stored procedures (if requested, I'll provide one of the stored procedures, but it's basically a complex search procedure). 3) To resolve the timeout error, we've found 2 temporary solutions:
A) have all clients exit the program thus closing all active connections (less than 10 connection in a 4-5 user setup) B) I run the following script when the timeout occurs and then the stored procedure runs smoothly:
Code Block
sp_configure 'remote query timeout', 0 reconfigure with override sp_configure 'remote query timeout', 600 reconfigure with override 4) Running the stored procedure from our application and from SQL Management studio express, is the same, except management studio doesn't time out and actually runs as long as it takes (roughly 1 minute 20 seconds or under 1 second after the script above runs).
We're pretty stumpted and it's happened at 5 different client sites with little in common. One of our sites is even running SQL express off the workstation with nothing else running and it still occurs.
I'm open to trying practically anything at this point, but unfortuntenly we have not been able to reproduce this behavior in our testing enviroment so I can't give much information for others to reproduce.
Environment: Sql Server 2000 Transaction Rep Distributor. Pub, Sub, and Distributor on separate machines.
Distributor Agent Gets: "Timeout expired (Source: ODBC SQL Server Driver (ODBC); Error number: S1T00)" and the Session Details of the the Distribution Agent says "The process is running and is waiting for a response from one of the backend connections." Of course, in true MS fashion, the message does not specify which connection it is waiting on. It could be waiting on the Publisher or it could be waiting on the Subscriber. Does anyone know how to tell? It would be quite useful to know which "backend" is indicated!
We get this event like clock-work at exactly the same times early every morning as well as at other random times during the day. I can not see any reason for it. Do you have any useful advice?
HiWe have an intranet portal site, using IIS 6, .NET 2.0 & SQL2005.One page is searching matched results in several tables and giving hints to the user using AJAX, IIS may send query to SQL pretty often. Normally it is very fast (<2s) to get the result and no problem. But occassionally someone (two different users in one week recently) might get the timeout (45s set in web.config) problem consistently while other users could get the result at the same time using the same query. The same user, same PC could run the same page correctly in another duplicated developing portal site during the probelm. It implies the problem is not in theclient side. This problem is gone automatically after a while (maybe half a day or one day, not sure yet).We do not use the window's authentication to access SQL2005, i.e., a common account is used; we do not find any abnormal on IIS server and SQL 2005 server when this problem happens.Any help/suggestion is highly appreciated.Thanks,WYW
Is there a way to execute a stored procedure and have it move on without waiting for a response from the stored procedure. I am trying to create a button on a webpage that will execute a stored procedure but the procedure takes to long to run and my page times out. Instead I would like the button to start the procedure and the webpage look at a table of data. When the table of data is empty then I will know the stored procedure is complete. Is this possible?
I want to know the differences between SQL Server 2000 storedprocedures and oracle stored procedures? Do they have differentsyntax? The concept should be the same that the stored proceduresexecute in the database server with better performance?Please advise good references for Oracle stored procedures also.thanks!!
hi i have given you the ado.net code to retrive a image from the database. I have tried using linq and i am getting a error in Response.BinaryWrite(rs.image) in LINQ. so i have used the ado.net which i dont want to use. can you pls help me how to correct the error.it says cannot convert linq.binary data... thanks Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyReader As SqlDataReaderDim MySqlConnection As SqlConnection Dim MySqlCommand As SqlCommandMySqlConnection = New SqlConnection("server=(local)SQLExpress;Integrated Security=SSPI;database=customs")MySqlCommand = New SqlCommand("select * from tbl_temp_importer_owner where TIN=555", MySqlConnection)
MySqlConnection.Open() MyReader = MySqlCommand.ExecuteReader()Do While (MyReader.Read()) Response.ContentType = MyReader.Item("PersonImageType")Response.BinaryWrite(MyReader.Item("PersonImage"))///Error come here in linq Loop MySqlConnection.Close()Response.Write("Person info successfully retrieved!")
SELECTa.Field2, a.Field3, b.Field3 FROM Tbl1 a INNER JOIN Tbl2 b ON a.Field1 = b.Field1 WHERE(a.[Name] LIKE '%@_name%') AND (a.ID BETWEEN @cPos AND @nPos) AND (a.Price BETWEEN @LPrice AND @HPrice) GO
if i remove @_name and put in '%%' it returns rows...but with @_name it doesnt work...any idea why?
check_syntax doesnt return any errors...so i dont kno waht to do
I have a stored procedure I'm using in a c# ASP.NET application. The SP is tied to an SQL DataSource which is, in turn, tied to a gridview control that displays the results obtained from the SP. The SP receives two parameters that are obtained from two dropdown list boxes. ALTER PROCEDURE developers.fort_GetSearchResults ( @propertyType int, @county int ) AS IF ((@propertyType = 1) AND (@county = 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id ORDER BY NEWID() ELSE IF ((@propertyType = 1) AND (@county != 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id WHERE (Experimental_Accommodation.propertyType = @propertyType) ORDER BY NEWID() ELSE IF ((@county = 1) AND (@propertyType != 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id WHERE (Experimental_ContactDetails.county = @county) ORDER BY NEWID() ELSE IF ((@propertyType != 1) AND (@county != 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id WHERE (Experimental_Accommodation.propertyType = @propertyType) AND (Experimental_ContactDetails.county = @county) ORDER BY NEWID() RETURN
Unfortunately only the first and fourth IF statement work. The second and third do not return any values and I'm unable to work out why.
I have a stored procedure I'm using in a c# ASP.NET application. The SP is tied to an SQL DataSource which is, in turn, tied to a gridview control that displays the results obtained from the SP. The SP receives two parameters that are obtained from two dropdown list boxes
Code:
ALTER PROCEDURE developers.fort_GetSearchResults ( @propertyType int, @county int ) AS IF ((@propertyType = 1) AND (@county = 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id ORDER BY NEWID() ELSE IF ((@propertyType = 1) AND (@county != 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id WHERE (Experimental_Accommodation.propertyType = @propertyType) ORDER BY NEWID() ELSE IF ((@county = 1) AND (@propertyType != 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id WHERE (Experimental_ContactDetails.county = @county) ORDER BY NEWID() ELSE IF ((@propertyType != 1) AND (@county != 1)) SELECT Experimental_Accommodation.id, Experimental_ContactDetails.name, Experimental_ContactDetails.address, Experimental_ContactDetails.district, Experimental_ContactDetails.town, Experimental_Counties.County, Experimental_ContactDetails.postcode, Experimental_ContactDetails.telephone, Experimental_ContactDetails.fax, Experimental_ContactDetails.email, Experimental_ContactDetails.contactName, Experimental_Accommodation.gradingDescription, Experimental_Accommodation.sleeps, Experimental_Accommodation.pricing, Experimental_Accommodation.shortDescription, Experimental_Accommodation.description, Experimental_Property_Type.name AS Expr1, Experimental_Grading.grading, Experimental_Images.filename, Experimental_Images.alt FROM Experimental_Accommodation INNER JOIN Experimental_ContactDetails ON Experimental_Accommodation.contactDetails = Experimental_ContactDetails.id INNER JOIN Experimental_Counties ON Experimental_ContactDetails.county = Experimental_Counties.id INNER JOIN Experimental_Property_Type ON Experimental_Accommodation.propertyType = Experimental_Property_Type.id INNER JOIN Experimental_Grading ON Experimental_Accommodation.grading = Experimental_Grading.id INNER JOIN Experimental_Images ON Experimental_Grading.iconId = Experimental_Images.id WHERE (Experimental_Accommodation.propertyType = @propertyType) AND (Experimental_ContactDetails.county = @county) ORDER BY NEWID() RETURN
Unfortunately only the first and fourth IF statements return a value. The second and third IF statements return nothing and I have no idea why.
the 1st uses the second sp. to fill a parameter. the 2nd has one output parameter defined.
When I run the 2nd sp. on its own in MS SQL Server Manangement studio, there is no resultset shown.
BUT when the 2nd sp. is executed inside the 1st sp., I get a '3' in the resultset everytime the 2nd sp. executes. What is causing this?????
This is the way I execute the 2nd sp. inside the 1st sp.: select 'TEST1' execute dbo.uspMonthlyHeadCount @soe, @eoe, @Months, @count output select 'TEST2'
Results are like this: TEST1 3 TEST2
... (it's displayed more times because the sp. is inside a while) Why is this happening and what can I do about it? (I'll provide more info if needed!)
In SQL 2005 I have a stored procedure as below:@sub_no smallint OUTPUTBEGINBEGIN TRANSACTIONINSERT...INTOSET @user_no = (SELECT ...... FROM ....WHERE sub_no = @sub_no)INSERT...INTOEXE another_stored_procedure (it includes also BEGIN...COMMIT)EXE another_stored_procedure (it includes also BEGIN...COMMIT)SET @sub_no = .......COMMIT TRANSACTIONWhen Visual Studio (ASP.NET 2005) is open and I run the program,procedure is executed once without any problem. If I publish theproject and put files on another server (or even use the publishedfiles from my machine) I have an error because stored procedure isexecuted twice. @sub_no is used as input/output parameter.I followed/trace the steps in procedure and it seems that procedure isexecuted once with correct value of @sub_no. The second time procedureis executed, the value that it was assigned before COMMIT is used,which gives an error because the INSERT values have NULL values.In ASP.NET I call the store procedure once.What could be the reason ?Thanks a lot for any help.
This Might be a really simple thing, however we have just installed SQL server 2005 on a new server, and are having difficulties with the set up of the Store Procedures. Every time we try to modify an existing stored procedure it attempts to save it as an SQL file, unlike in 2000 where it saved it as part of the database itself.
Using SQL 2005, SP2. All of a sudden, whenever I create any stored procedures in the master database, they get created as system stored procedures. Doesn't matter what I name them, and what they do.
For example, even this simple little guy:
CREATE PROCEDURE BOB
AS
PRINT 'BOB'
GO
Gets created as a system stored procedure.
Any ideas what would cause that and/or how to fix it?
How do I search for and print all stored procedure names in a particular database? I can use the following query to search and print out all table names in a database. I just need to figure out how to modify the code below to search for stored procedure names. Can anyone help me out? SELECT TABLE_SCHEMA + '.' + TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'
Hello, I have to transfer lets say once a day arround 30 000 records from one table into another. The query uses cursor and should check if the record exists to make update, otherwise to make insert. On this ammount of data, in visual studio I get Connection Timeout. I even unselected "Cancel long running query" in Tools/Options/Database tools, and I still get timeout. When using Sql Server management studio it works and it takes long time. I know that this query executes long time, but it will run in the middle of the night and nobody will bother. I could have transfered this data in the application and then return it to the database one by one, but why unnecesary transport? How do I get the stored procedure running without this timeout? Thanks
I am having a problem with a long running stored proceudure timing out in a web page. Details:
In ASP page - run stored procedure After approx 30 seconds, I get the error msg:
Microsoft OLE DB Provider for ODBC Drivers error '80040e31'
[Microsoft][ODBC SQL Server Driver]Timeout expired
xxx.asp, line 284
(this is where the exec statement is for the stored procedure)
The procuedure takes approx 2:20 to run directly in Query Analyzer. Any ideas on how to ensure that the page waits for the entire query to finish and return results? I suspect that some fine tuning can be done on the procedure but it will still take longer than the 30 seconds that the browser is giving it to run...
Notes - query works. takes 2:20 to complete. ASP - Server Timeout set to 600 seconds for the ASP page. SQL Server timeout set to 0 (unlimited) SQL 7 SP1 applied
Seems like I'm stealing all the threads here, : But I need to learn :) I have a StoredProcedure that needs to return values that other StoredProcedures return.Rather than have my DataAccess layer access the DB multiple times, I would like to call One stored Procedure, and have that stored procedure call the others to get the information I need. I think this way would be more efficient than accessing the DB multiple times. One of my SP is:SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, S.Name AS 'StatusName', S.ItemDetailStatusID, S.InProgress as 'StatusInProgress', S.Color AS 'StatusColor',T.[Name] AS 'TypeName', T.Prefix, T.Name AS 'ItemDetailTypeName', T.ItemDetailTypeID FROM [Item].ItemDetails I INNER JOIN Item.ItemDetailStatus S ON I.ItemDetailStatusID = S.ItemDetailStatusID INNER JOIN [Item].ItemDetailTypes T ON I.ItemDetailTypeID = T.ItemDetailTypeID However, I already have StoredProcedures that return the exact same data from the ItemDetailStatus table and ItemDetailTypes table.Would it be better to do it above, and have more code to change when a new column/field is added, or more checks, or do something like:(This is not propper SQL) SELECT I.ItemDetailID, I.ItemDetailStatusID, I.ItemDetailTypeID, I.Archived, I.Expired, I.ExpireDate, I.Deleted, EXEC [Item].ItemDetailStatusInfo I.ItemDetailStatusID, EXEC [Item].ItemDetailTypeInfo I.ItemDetailTypeID FROM [Item].ItemDetails IOr something like that... Any thoughts?
I have MSSQL 2005. On earlier versions of MSSQL saving a stored procedure wasn't a confusing action. However, every time I try to save my completed stored procedure (parsed successfully ) I'm prompted to save it as a query on the hard drive.
How do I cause the 'Save' action to add the new stored procedure to my database's list of stored procedures?
We recently upgraded to SQL Server 2005. We had several stored procedures in the master database and, rather than completely rewriting a lot of code, we just recreated these stored procedures in the new master database.
For some reason, some of these stored procedures are getting stored as "System Stored Procedures" rather than just as "Stored Procedures". Queries to sys.Objects and sys.Procedures shows that these procs are being saved with the is_ms_shipped field set to 1, even though they obviously were not shipped with the product.
I can't update the sys.Objects or sys.Procedures views in 2005.
What effect will this flag (is_ms_shipped = 1) have on my stored procedures?
Can I move these out of "System Stored Procedures" and into "Stored Procedures"?
I am running a large insert in a stored procedure, and it is timing out after 30 seconds (which I take to be the default). Can anyone tell me how to change the timeout from inside the stored procedure?
im testing an application change that should handle a timeout on a stored procedure being called from the application. thing is, the timeout that we experience in production that led to this fix is random. so is there some way for me to setup a test stored procedure or some way to call the SP so that i can test a timeout scenario? im using MFC and the CDatabase::ExecuteSQL method to call this SP if you were wondering at all. this app is running locally on the server that has an instance of SQL Server Express 2k5 on it. server is running win 2k3.
In simple terms, our system is as such: We have a website. As someone clicks a button on the website, a stored procedure is executed against our database.
Every single day, between 12:15AM and 12:45AM we have a few stored procedures timing out, with the following message, for example:
2007-04-10 00:37:03,268 [3632] ERROR Service - caught exception Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection)
I checked and saw that although there are jobs running at that time, all of these jobs are running periodically (e.g. every 30 minutes) and would cause timeouts at other times as well, if they were to blame. Other jobs are running at far away times and checking their history I know that their duraion in no way intersects the time-out times.
I also ran profiler during peak hours and know that no stored procedure of ours has a duration anywhere near 30 seconds (which is the currently set timeout period, although all of our sps run within milliseconds).
I am really puzzled as to what exactly is causing these timeouts. Would anyone suggest any approach to identify the problem. For example, I thought about running profiler (server side tracing) between 12AM and 1AM, but am not sure which counters are best to capture. Any suggestion on this?
I Have a problem When I execute a stored procedure from query analyzer (Exec storedname @parameter1='', @Parameter2='') it take 7 min. and I stop running
If I copy stored procedure , past it in Query analyzer and declare parameters it take 3 sec.
Hi, I'm running a CLR stored procedure through my web using table adapters as follows: res = BLL.contractRateAdviceAdapter.AutoGenCRA() 'with BLL being the business logic layer that hooks into the DAL containing the table adapters. The AutoGen stored procedure runs fine when executed directly from within Management Studio, but times out after 30 seconds when run from my application. It's quite a complex stored procedure and will often take longer than 30 seconds to complete. The stored procedure contains a number of queries and updates which all run as a single transaction. The transaction is defined as follows: ---------------------------------------------------------------------------------------------------------------------- options.IsolationLevel = Transactions.IsolationLevel.ReadUncommittedoptions.Timeout = New TimeSpan(1, 0, 0) Using scope As New TransactionScope(TransactionScopeOption.Required, options) 'Once we've opened this connection, we need to pass it through to just about every 'function so it can be used throughout. Opening and closing the same connection doesn't seem to work 'within a single transactionUsing conn As New SqlConnection("Context Connection=true") conn.Open() ProcessEffectedCRAs(dtTableInfo, arDateList, conn) scope.Complete() End Using End Using ---------------------------------------------------------------------------------------------------------------------- As I said, the code encompassed within this transaction performs a number of database table operations, using the one connection. Each of these operations uses it's own instance of SQLCommand. For example: ----------------------------------------------------------------------------------------------------------------------Dim dt As DataTable Dim strSQL As StringDim cmd As New SqlCommand cmd.Connection = conn cmd.CommandType = CommandType.Text cmd.CommandTimeout = 0Dim rdr As SqlDataReaderstrSQL = "SELECT * FROM " & Table cmd.CommandText = strSQL rdr = cmd.ExecuteReader SqlContext.Pipe.Send(rdr) rdr.Close() ---------------------------------------------------------------------------------------------------------------------- Each instance of SQLCommand throughout the stored procedure specifies cmd.CommandTimeout = 0, which is supposed to be endless. And the fact that the stored procedure is successful when run directly from Management studio indicates to me that the stored procedure itself is fine. I also know from output messages that there is no issues with the database connection. I've set the ASP.Net configuration properties in IIS accordingly. Are there any other settings that I need to change? Can I set a timeout property when I'm calling the stored procedure in the first place? Any advice would be appreciated.
I am writing a set of store procedures (around 30), most of them require the same basic logic to get an ID, I was thinking to add this logic into an stored procedure.
The question is: Would calling an stored procedure from within an stored procedure affect performance? I mean, would it need to create a separate db connection? am I better off copying and pasting the logic into all the store procedures (in terms of performance)?
I have a stored procedure when query a big table about 500,000 records. When I run the stored procedure in the query analyzer, it is very fast and it only takes 2~3 seconds. However, when my aspx page try to call this stored-procedure with a Command's ExecuteReader method like bellow:
I always get timeout expired exception. I try to set the connection timeout and command timeout to 100 seconds. The exception is gone but the average execution time is about 25 seconds! While the stored-procedure only takes about 2~3 seconds in query analyzer with the same parameter.
What could be the problem?? I tried to figure this out for a couple days but still no clue.