The sqlserv.exe takes too much CPU utilization on my SQL 2000 on W2K production machine. I am tring to use System Monitor to monitor the Thread/%process time with all Sqlservr instances, and then match the sqlservr instance number to the KPID in sysprocesses table to find out which user is causing the problem. but I can only see the instance number from Sqlservr0 to sqlservr99. From the table sysprocesses table, the KPID is all 3 or 4 digits number. Any one has any idea about this?
ProductCode - CenterId - Region 13265 - 10 - Asia 13265 - 12 - Asia 13265 - 9 - America 11110 - 10 - Asia 11110 - 9 - America 12365 - 12 - Asia 12365 - 8 - Europe 45620 - 10 - Asia 45620 - 12 - Asia
What I need this query to do is to pull one instance of a product code where the "Asia" appears more than once within the table? Thanks for the help!
Just wondering if there is any way to kill a thread within an sqlerver process. The thread we are trying to kill is a rollback statement that has been running for a very long time.
The thing that I dont understand is, where the thread get the information from? My windows application currently set to "zh-CHS" culture but my pc that running the application is "en-US".
It seems like the thread get the information from my pc. What i want is, getLanguage get the information from the application.
I receive the following errors while browsing the http://server/reports page.Please help me to resolve the issue.
Error1.
Thread was being aborted. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Threading.ThreadAbortException: Thread was being aborted. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ThreadAbortException: Thread was being aborted.] System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +483 System.Web.HttpApplication.ResumeSteps(Exception error) +539 System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +144 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +300
Error2.
The report server cannot decrypt the symmetric key used to access sensitive or encrypted data in a report server database. You must either restore a backup key or delete all encrypted content. Check the documentation for more information. (rsReportServerDisabled) (rsRPCError) Get Online Help Bad Data. (Exception from HRESULT: 0x80090005)
I have identified that one of the instance is taking much more CPU than the other by using the counter process\% processor time in perfmon. So we have decided to monitor only that instance using ID Thread counter to see which process is causing this high usage within this instance.
Now problem... Thread ID is re-used by Windows. We cannot identify which counter is the one causing problem at that point of time just using the ID from a report given to me NEXT DAY because I can never dream of monitoring the server in the real time to see what is the process Thread ID NOW.
Now question.. Is there is any counter that says which process caused the spike in %CPU used at one point of time from the thread id comparing against another counter in perfmon?
I have never worked with this in detail before. If any one can give me the counters and the method to identify which process is related to which thread at that point of time from a report received NEXT DAY MORNING, thanks a lot.
Hello, I have built a system, that uses a .dll file for all SQL operations. So a program looks something like this: using myDLL; .... SQLDBCON mSQL = new SQLDBCON(); and here comes the rest of the program. My question is, the dll file has all stored procedures and when you declare mSQL as shown above, then it opens a thread to the database for that user. Is that thread properly closed when the site has finished loading? in my .aspx page i dont have a function like mSQL.CloseDB(); and if i try to add something like this to the dll file ~SQLDBCON { m_local_con.Close();m_local_con.dispose(); } i get a error message says something that this is not allowed. Just want to know if my thread in the dll file is properly closed?
Hi all, I am having problem with SQL connection at Godaddy where my pool connection gets MAX OUT. When it happens, I cannot access the database.This is the thread about the problem: http://forums.asp.net/thread/1665023.aspx I just created this with "THREAD". I hope someone who has experiences with thread can give me some advice about my design. This is my first time.
static object Locked = new object(); public object ExecuteCommand(string queryStr, string type){ //*************************************************************************************// // ExecuteCommand: Returns an object // //*************************************************************************************// Thread t = null; lock(Locked) { SQLString = queryStr; switch(type) { case "ExecuteNonQuery": t = new Thread(ExecuteNonQuery); break; case "ExecuteScalar": t = new Thread(ExecuteScalar); break; case "GetDataReader": t = new Thread(GetDataReader); break; } t.Start(); t.Join(); } return null;} First of, does this work at all? It runs, but is it a good design in term of Thread? Since I use LOCK, do I still need the t.Join() function? The switch with the three cases, is that OKAY? Basically, I'm clueless. If you read my other post, you will get an idea what I'm trying to do. Any feedback would be very very appreciated. Thank you.
I am currently using @@Identity to retreive the Identity value for the PK field in a table that I am inserting data into. Essentially, my code looks like this:SqlCommand cmd=new SqlCommand("Insert into table(... ;Select @@Identity from table",conn);string identity=cmd.ExecuteScalar();Testing this myself, it works fine, but I am worried as to how thread safe this is in a real-world environment? (i.e. with multiple users clicking at it). Is there a guaranteed way to make this thread safe- wrap it in a transaction maybe?
I'm making a "simple" ASP forum to integrate into a webpage solution. I just recently ran into a problem with sorting threads. I have a page that displays all threads in a given forum (Threads.ThreadForumID=iForumID) this page will have all pinned threads on top of the list the threads should then be sorted according to when a message last was posted inside the thread (Posts.PostDate)
Sort order: Threads.ThreadPinned Posts.PostDate or Posts.LastPostDate if it has been set.
The tables are as follows: Threads table: ThreadIDNumber ThreadNameText ThreadViewCountNumber ThreadOwnerIDNumber(Ref to thread owner id, user) ThreadLockedBoolean ThreadPinnedBoolean ThreadForumIDNumber(Ref to ForumID, forum)
Posts table: PostIDNumber PostTextText PostOwnerIDNumber(Ref to post owner, user) PostLastEditByNumber(Ref to last user that edited, user) PostThreadIDNumber(Ref to thread) PostIPText PostNicknameText PostDateDate PostLastEditDateDate
Current "sort": This is the current SQL statement it is not in any way correct. It's just temporary. I have tried different joins but I can't seem to get it right!
SELECT ThreadID FROM Threads WHERE ThreadForumID=" & iForumID & " ORDER BY ThreadPinned DESC, ThreadID DESC
I am having a problem with the SQL Server 2005 database of our ERP system. We have a scheduled batch that gets stuck because of a lock on a table. The lock remains overnight and halts all other processes (it seems most of them are waiting for this lock to get solved) I know which table the lock is on and if I kill the lock manually, the batch continues and finishes without a problem
my question is: can I change this behaviour somewhere?
The piece of code that causes this lock is protected, but in a debug log I was able to see that it happens during following actions:
first a select is performed to fetch a certain record in the file that gets locked next an update is performed with following syntax:
update ... set.... where current of 'pointername'
this update is waiting for a lock to be released before the batch continues.
My guess is that somehow the pointer that is set with the select statements, locks the row and that's why the update cannot be performed. The strange part is that this lock does NOT occur everytime that this table needs to be updated. And that's why I am stuck and asking help of the real database people :)
If someone can give me a hint on a setup,property, or just a pointer to where I can find more info on the 'why'-part of the lock, I would be very grateful
Newbie question, but is there a way for me to set up a thread in my c# code so as it sleeps until it gets woken up by an event fired by an activation SP?
As in queue sits idle, thread sleeps. Queue receives a message, activation SP gets fired, activation SP raises an event which gets caught by event handler in code, which wakes up thread to do processing?
When a query is executed, the tab is split horizontally with the bottom half containing two tabs. The first with the result set(s) and the second with the messages.
How do I hide the bottom half after I have read it and now want the entire column to view my TSQL? Is there some menu item or shortcut key that I can use to accomplish this?
In 2000, there is a configuration option to make these tabs appear at the top of the window. I haven't found this setting in Express.
Another nice feature that I appreciate is to be able to divide the window into independant horizontal or vertical windows (or tabs) each with different files. I have found that I can get there with a mouse click but I could use some guidence in restoring the original layout, expecially without closing the windows.
I have been struggling with this error for a while now. Not much when I put it in the search engines. I get the error as follows when I execute this CLR stored procedure:
Msg 10312, Level 16, State 49, Procedure SpPICK00, Line 0
.NET Framework execution was aborted. The UDP/UDF/UDT did not revert thread token.
The code for the stored procedure is as follows. If anybody could offer any advice on what this error means I would appreciate it. I know through debugging that it's erroring out on the ImpContext = ClientID.Impersonate() line.
Dim DbCon As New SqlConnection("context connection=true")
Dim DbSql As New SqlCommand("SELECT TOP 1 * FROM TblTransactions", DbCon)
Dim TransactionID As Int64
DbSql.Connection.Open()
Dim DbRs As SqlDataReader
DbRs = DbSql.ExecuteReader
While DbRs.Read
TransactionID = DbRs("TransactionID")
End While
DbRs.Close()
Dim MenuID As Int16
Dim MONumber As String
Dim LineNumber As String
Dim PTUse As String
Dim SEQN As String
Dim WorkCentre As String
Dim Stock As String
Dim Bin As String
Dim Qty As Double
DbSql = New SqlCommand("SELECT * FROM VwPickList WHERE TransactionID = @TransactionID", DbCon)
Hi I'm using a gridview to show a list of high scores in a c#.net page. The position of the score is not stored in the database, just the score, name and id. In the gridview however I would like to indicate the position of the scores, the SQL statement sorts the records by ascending scores so the are already in the correct order. Does anybody know how to include a counter in the SQL statement that I can refer to vai the gridview so that it is able to display it as the position? Thanks in advance for any help!
# 1 - You want a Multipage Hit Counter to keep track of the number of Hits each individual webpage gets in your website. # 2 - You also want to store the Webpage Hit Count Values into a SQL Database, using Stored Procedures.
Dim objCon As New SQLConnection("server=yourServerName;User id=idName;password=yourPassword;database=HitsCounter")
Dim cmd As SQLCommand = New SQLCommand("EXEC dbo.webcounter1", objCon)
objCon.Open()
Dim r as SQLDataReader
r = cmd.ExecuteReader()
r.read()
strcounter3.text = "Hits : " & r.item(0)
end sub
</script>
Also insert the following inside the body tags of webpage #1 <asp:Label id="strcounter3" font-size="X-Large" font-bold="True" bordercolor="Silver" width="300px" borderstyle="Inset" forecolor="Lime" visible="True" runat="server"></asp:Label>
Marked in Red webcounter1 is the Stored Procedures Name. ALso marked in<B> Red counter3 is the name of the Database. This is where you would make your changes inside the Webpages.
Use the following Stored Procedure with Webpage #1
CREATE PROCEDURE dbo.webcounter1 WITH RECOMPILE AS BEGIN SET NOCOUNT ON DECLARE @hits INT SELECT Hit FROM counter3 WHERE ID = 1 update counter3 set hit = hit + 1 EXEC sp_recompile counter3 END GO
The Database Table has 2 columns which consists of an ---ID & Hit Column -- The Table Name is (counter3) The best way to explain is by showing so posted below are Webpages 1 & 2 along with there Stored Procedures.
Dim objCon As New SQLConnection("server=yourServerName;User id=idName;password=yourPassword;database=HitsCounter")
Dim cmd As SQLCommand = New SQLCommand("EXEC dbo.webcounter2", objCon)
objCon.Open()
Dim r as SQLDataReader
r = cmd.ExecuteReader()
r.read()
strcounter3.text = "Hits : " & r.item(0)
end sub
</script>
Also insert the following inside the body tags of webpage #2 <asp:Label id="strcounter3" font-size="X-Large" font-bold="True" bordercolor="Silver" width="300px" borderstyle="Inset" forecolor="Lime" visible="True" runat="server"></asp:Label>
Use the following Stored Procedure with Webpage #2
CREATE PROCEDURE dbo.webcounter2 WITH RECOMPILE AS BEGIN SET NOCOUNT ON DECLARE @hits INT SELECT Hit FROM counter3 WHERE ID = 2 update counter3 set hit = hit + 1 EXEC sp_recompile counter3 END GO
Now this type of Hit Counter works fine to a point. Visiting Webpage #1 accumilates 1 Hit & Visiting Webpage #2 Accumilates 2 Hits. And each time there 's a revisit to these pages they acquire 2 Hits each. I'm Guessing the problem is in the Stored Procedure storing there values in Memory. If Someone can Help Figure Out how to fix this. This could be a nice Website Multipage Hit Counter. I can use some help Guys feel free to advise.
I'm trying to write a select that returns a result set with a counter added on. I want to do it without using an identity column or cursor. Something along the lines of select col1, max(col2)+1 from tab1. I get (as expected)
I am looking to create a incremental value based on the resulting insert that I am using. There already is another field being used as an identity field. I have a beginning value that I just want to add the row number to for the insert.
insert into lineitem select substring(group_id,4,len(ltrim(rtrim(group_id)))-3) as co_code, 0,0,(case when enddate < cast(month(getdate()) as varchar(10))+cast(day(getdate()) as varchar(10)) then 'Prior' else 'Current' end ), left(acct_type,2) as bene_type, convert(smalldatetime,left(ltrim(rtrim(eff_date)), 8)), 0,trans_amt,0,0,convert(smalldatetime,left(ltrim(r trim(sett_date)),8)), ltrim(rtrim(b.fname)) + ' ' + ltrim(rtrim(b.lname)) as payee,0,0,a.ssn,'Y',999+count(*), (case when isnull(b.location,'') = '' then '' else b.location end) as location from mbi_tran_temp a left join enrollees b on a.ssn = b.ssn and ltrim(rtrim(a.group_id)) = ltrim(rtrim(b.mbicode))
The '999+count(*)' is where I would like to have the incremental value.
It sound like a simple task to perform but I just can't seem to get it. I've built a search function on the site and after each search request, a log is kept of the search word and the date, so the table looks a little like this:
My client wants IN_PUNCH to be the first in punch of the day and the OUT_PUNCH to be the last out punch of the day based on the TransactionDate as it is showing in the desired results table for 07/29 and 07/30 (Changes are highlighted in Bold).
I tried using MIN and MAX at different areas but to no avail.Also, is there a way to add a counter at the end of each row so in case if there were two shifts in a day then it be a '1' for row 1 and a '2' for row 2?
WITH SampleData (PERSON,TRANSACTDATE, STARTDATE, END_DATE, IN_PUNCH,OUT_PUNCH,HOURS,PAYCODE,SHIFT_LABEL,DOW) AS ( SELECT 1234,'07/27/2015','07/27/2015','07/27/2015', '12:00','12:00','8', 'Hol', 'NULL', 'Monday' UNION ALL SELECT 1234,'07/28/2015','07/28/2015','07/28/2015', '08:00','','4.00', 'Absent', 'Batax 1st','Tuesday' UNION ALL SELECT 1234,'07/28/2015','07/28/2015','07/28/2015', '12:15','14:00','3.75', 'Regular', 'Batax 1st','Tuesday' UNION ALL
I need to count the days (24 hours)from the (GETDATE()),returning an integer in a table column, automatically, all the time , under the scene until after a specified number of days (usually 20 for example), the relevant table row is be automatically deleted, replaced by another insert (row) to start again and the process repeated many times.
I have a database which works automatically. The data need not to be queried or manipulated until the row is deleted automatically. I use SQL Server 2000.
Any ideas of doing this in a simple way ? Regards and thanks in advance.Yves.
this procedure resets the business day to one for every month. It works fine except for the month of October. any idea or suggestions?
DECLARE @i INT SET @i = 1 DECLARE @DateID INT, @DtTimeD DATETIME, @LASTDAY DATETIME DECLARE c CURSOR FOR -- -- LASTDAY is the last day of the month -- the counter will reset to 1 on the first of each month -- SELECT DateID, DtTimeD, DATEADD(dd, -DAY(DATEADD(m,1,DtTimeD)), DATEADD(m,1,DtTimeD)) 'LASTDAY' FROM D_DATE WHERE WkDayIn = 'Yes' AND HolidIn = 'No' OPEN c FETCH NEXT FROM c INTO @DateID, @DtTimeD, @LASTDAY WHILE @@FETCH_STATUS = 0 -- -- update the business day in D_DATE -- BEGIN UPDATE D_DATE SET BusDay = @i WHERE DateID = @DateID -- -- reset the counter to 1 if it's the last day of the month -- IF @DtTimeD = @LASTDAY SET @i = 1 ELSE SET @i = @i + 1 -- IF @@ROWCOUNT = 500 COMMIT -- FETCH NEXT FROM c INTO @DateID, @DtTimeD, @LASTDAY END CLOSE c DEALLOCATE c GO
I have a form that I turned off the nav buttons. I then create my own.The reason I do is that I cna then move the nav buttons any where I needto on the form.The only thing I can not figure out is on the default ones, it shows thetotal records. I can not figure out how to do this. The form is based ona table and when I add a record or delete a record I want to make ssurethe total displayed is correct.How can I display the total records, for the table, on the form on thefly?Does that make sense?Michael Charneym charney at dunlap hospital dot org*** Sent via Developersdex http://www.developersdex.com ***
While inserting data into a target table, I'm trying to populate a primary key ID field sequentially. For each record, the value of the primary key field needs to be incremented by one (a counter).
I've tried to use the RowCount transformation to store the values in a variable. I'm able to successfully do that; however, I don't know how to read or update the variable incrementally.
If someone knows how to perform this task, please let me know. I would greatly appreciate it.
Hi, How do we set credentials or contex to a thread. I create a new thread and within that thread if I am use a connetion string with Integrated Security=True" to talk to the SQL Server, however it seems that the new thread's context/identity is blank and hence failing the SQL Server connection. Please help. Thanks
all of the sudden two days ago there are error messages started to appear in SQL Log, the server slows down substantially during these errors occurance:
SQL Server could not spawn process_loginread thread.
and
ERROR: Launch of System Task 'OnDemand' failed!
Any ideas of the best way to troubleshoot/reproduce it?
I run SQL2000 Ent on NT Server 2000 Advance. SP3a installed. 3.5Gb memmory allocated to the server with AWE anabled.
Sql version Microsoft SQL Server 2000 - 8.00.818 (Intel X86) May 31 2003 16:08:15 Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4)
I have dts running 24 X 7 every 5 minutes I noticed DTS failed few times a day with error
Step Error Source: Microsoft OLE DB Provider for SQL Server Step Error Description:Transaction (Process ID 74) was deadlocked on thread | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Step Error code: 80004005 Step Error Help File: Step Error Help Context ID:0
The is no entry about in Server server log files. will trace identify deadlock and why deadlock info not entred into log file ?