I have written a very short program to get information from a whole
table out of a database. the problem is that other people couldn't
work on this table during the process. It seems that my program locks
the whole table.
I used the DataReader from the .NET Framework. Can you please take a
look at the code and give me any solution??? Thank very much, Nils
Dim strSQL As String = "SELECT * FROM TESTTABLE"
Dim Conn As System.Data.SqlClient.SqlConnection = New
System.Data.SqlClient.SqlConnection("Data Source=1.1.1.1;
User ID=sa;Password=secret;Persist Security Info=True;
Initial Catalog=TestDB")
Conn.Open()
Dim SqlCmd As SqlCommand = New SqlCommand(strSQL,Conn)
Dim DR As System.Data.SqlClient.SqlDataReader
Try
DR = SqlCmd.ExecuteReader
Do While DR.Read()
<only reading with DR.item("columnname")>
Loop
Catch ex As Exception
errorhandler(ex.ToString)
Finally
If DR.IsClosed = False Then DR.Close()
SqlCmd.Dispose()
End Try
I understand that when you create a Temporary table with '#tablename', the table is only visible for the current session. I have an application which connects to sql server with the same sql account details.The reason for explaining this is that I can have multiple concurrent sessions for the same user. Each of these sessions will run a report by calling a stored procedure which would create a temporary table of the same name. I found that the response times vary when running the stored procedure concurrently with the same user. From viewing the activity from sql server, I noticed some blocking occurs. Is there any way to improve on this set up
I get a 90-120 second blocking when send 15 or so simultaneous queriesto SQL Server 2000 that query a view made up of two joined tables.After each query is blocking for the same amount of time they allreturn. Further identical queries of this type work in 3-4 seconds(caching?) until hours later where it happens again. If I query thetables directly (without the view) I still get the same blocking. If Iremove the join (it is a simple inner join on two columns) I do not getthe blocking.Any ideas?
as far as I know from docs and forum datareader is for .NET data in memory. So if a use a complex dataflow to build up some data and want to use this in other dataflow componens - could i use data datareader source in the fist dataflow and then use a datareader souce in the second dataflow do read the inmemoty data from fist transform to do fursther cals ?
how to pass in memory data from one dataflow to the next one (i do not want to rebuild the logic in each dataflow to build up data data ?
Is there a way to do this ? and is the datareader the proper component ? (because its the one and only inmemory i guess, utherwise i need to write to temp table and read from temp table in next step) (I have only found examples fro .NET VB or C# programms to read a datareader, but how to do this in SSIS directly in the next dataflow?
One sql transaction is in rollback state and optimization job is trying to restructure index on the same table that this transaction is using. As a result, transaction is in 'blocking' state and optimization job is in 'blocked' state. 'Kill process' doesn't do anything. How can this situation be resolved?
Is it possible that blocking can occur between a select and update statements running at the same time on the same object??thanks for the reply! Sheila.
Anyone out there having "self blocking" issues since upgrading to SP4 on SQL 2000? Enabing trace flag 9059 has not helped, is this a parallelism issue ?
INSERT INTO #XLAT_BCP_Results(Col1) Exec(@Command_String)
MOVE DATA FILE TO ARCHIVE COMMIT TRAN ANOTHER FETCH
A spid is launched to do the bcp...I have 4 files...on the last load The connection Pooling lauched spid gets blocked by the sa spid that launched the sproc...it doesn't happen all the time, just most of the time....
I've put a trace on in Profiler, but I don't see anything...I've picked the event class of deadlocks...but I never see it...
Hi just read an article on the internet that states
"A quick way to resolve a blocking problem is to disconnect the connection blocking the rest of the users. All you have to do is ask your database administrator to execute the KILL statement. Obviously, this is not a permanent solution, and won't really help anything except take care of an immediate need."
Now when i run sp_who ... i see that the spid that is blocking is the same as the spid itself....
Now the above article states that killing the one that is blocking the rest of the other spids is ok ...
But what if its the same SPID that is blocking ...what does it signify & whats the solution
I am running a simple SELECT statement on my TempDB
SELECT * FROM TempDB..SysObjects
When I run this , it's getting blocked by some other Process which is not at all relevant to the above Qry. First it gets blocked by one Stored Proc say Proc1 ( The Proc1 is just a SELECT statement on a table which just has four rows ). So I just kill this PROC1 and again its gets blocked by some other stored Proc PROC2 which again is a simple stored Proc and it runs in not time.
hi,I am using SQL SERVER 2000.Problem that i am facing is when ever I check locks in EnterpriseManager I findfollowing blocking - :1) sp_cursoropen;12) sp_cursorclose;13) sp_cursorfetch;1We dont have any control over application(source code).Whateverwe have to do, has to done from database side.can anyone guide me to solve this problem.Thanks
Hey guys, whats an easy way to pass a value into a stored procodure? I tried the code below but I keep on getting a "Procedure 'sp_InsertData' expects parameter '@gpiBatchNo', which was not supplied." error. My stored proc basically gets inserts the passed variable into a databaseSqlConnection sqlSecConnection = new SqlConnection(sqlPriConnString);SqlCommand sqlSecCommand = new SqlCommand(); sqlSecCommand.Connection = sqlSecConnection; sqlSecCommand.CommandText = "sp_InsertData";sqlSecCommand.CommandType = CommandType.StoredProcedure;sqlSecCommand.Parameters.Add("@gpiBatchNo", SqlDbType.NVarChar) ; sqlSecConnection.Open();int returntype = sqlSecCommand.ExecuteNonQuery(); sqlSecConnection.Close();
I have one batch jobs running 4 time a day and web application. We have hosted the site long time already but this month we are facing the store procedure blocked problem. The problem is that when user submit the form when during the execution of batch job, two storeprocedure are blocked. One store procedure that is using from batch job read the table "A" and another store procedure that is using from web app update the table "A". Then deadlock is occure. but i don't understand it is hosted long time already. Please let me know if you know how to solve this issue. Thanks, Aung
I have a powerbuilder application that is connecting to SQL Server. We get very frequent DeadLock situations. Is there a way that I can check to see as what SQL is causing the Lock?
I have upgraded a MS SQL database from 6.5 to 7.0. The database functioned fine in 6.5, now I have a table that is locking due to a blocking process. If I kill the process all is fine, but am trying to determine what is causing the process to hang. Has anyone experience any similar situations.
In the morning at 9:32 one of the spid was blocked and got time out msg for select statement. the statement was sp_execute wht is sp_execute? can anyone guide me?
I've a problems with blocking simple select * from table1 is blocked how to know which statement is blocking select * from table1 is spid 30 blocked by spid 26 and in current activity spid 26 has no select or any statement how could i know the spid 26 statement ? And can just select statement be blocked?
I know that spid 22 is blocking 2 other users. How do I tell who that user is? Is this just matching the same spid# in the process info in EM and if it doesn't give me an NT name it's probably because they're coming through the application and I can't figure it out?
I've a encountering a problem with "Blocking" and would highly appreciatd, if anyone out there please advice how to get to the bottom of this. the problem in as follows:
Every now and then, my SQL Server Freezes and when i look at the process info, i see some user connections in blocked mode and some in blocking. i dont know, where to start looking for. my first question would be, what should I do here? Should i kill the blocked user or blocking user? Also, Whats the difference between this two modes (blocked and blocking) and why does this happening? can i trace the user id which is causing this problem?
Experts please advice, what to do in the near future to aviod this.
I search at microsoft support site and came up nothing good about this problem.
When an SA attempts to change permission on any object they are shown as blocked as expected. However as new users access the object the SA's process is continuely blocked until the object is free. Can anyone explain this??
I have a sql2K SP3 active/passive failover cluster running on W2K SP4. I epxerienced a blocking scenario. The blocking process was killed only to find another process cause blocking. Killing the blocking process didn't resolve the blocking issue. Eventually I had to fail over the SQL Server instance to another node and that brought resove the blocking issue. What direction should I look for investigation and solution. URGENT PLEASE.
I have a vendor supplied database which seems to have a simple blocking problem. The blocking will occur when a user tries to delete from a table where another user might be inserting or selecting from. The table has only 3 columns and the delete statement looks fine. (they are not deleting the same record) This is on SQL 2000 sp1. has anyone seen this or have any ideas. The db is on a fast server (quad 2 gig of ram). I did have the thought on a problem I ran into with an older db on SQL 7 where the write-ahead RAID controller was actually causing a simlar problem. Any help appreciated
Hi All, I have a hypothetical scenario. I have few developers who all know the sa password. I want to block one developer from accessing the SQL server eventhough he knows the sa password.
Do we have any mechanism in SQL Server 2000 to block client based on the IP address of the client?
SQl Server is installed on Windows 2000 server. It uses SQL Server & Windows authentication.
I don't understand why a CREATE PROC from 3.5 hours ago is the head blocker. The SP wasn't changed since in months so this must be a compile/recompile? It's not a COMPILE lock though but a PAGE lock. It's certainly not the initial creation. What else can be done to debug this? It's happening and usually resolving itself in 4-6 hours or if I kill the head blocker myself. It doesn't happen every day but almost every day.
I've retrieved this info about the blocking from DMVStats and found similar info using my regular blocking info script also pulling info from DMV's.
I'm running SQL 2005 SP2 Enterprise.
statement started 6:35AM waiting statement (PAGE lock):
insert into grades (blah,blah) select blah blah from homework join blah blah
statement started at 3:01AM blocking statement: ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[ResultsHomeworkDelete] @homeworkResultId int, @NumDeleted int output AS
delete homeworksessions where homeworkresult_id = @homeworkresultId
set @NumDeleted=@@ROWCOUNT
delete homeworkresults where homeworkresult_id=@homeworkresultId
MOM contains its own Block Analysis script. It is a script written onVB, that looks for the monitored servers, creates for each oneMomCreateObject("SQLDMO.SQLServer"), afterwards connects to eachdatabase on each server and executes SELECT GETDATE() query. If MOMdoesn't receive answer for 6 minutes, it sends alert. Several timessince I started to monitor my servers I received the next alert:The program "SQLDMO_789" has been blocked for 6 minutes on databaseBurstingDataWarehouse in the SQL instance MSSQLSERVER. The definedacceptable blocking threshold is 1 minute(s). "SQLDMO_789" is runningon SPID 134 as login NT AUTHORITYSYSTEM and is blocked by SPID 133.The resource id is KEY: 10:2:1 (a2007950f190)SQLDMO_789 - is the MOM itself (number varies from time to time). 10 -is BurstingDataWarehouse database. As far as I can judge, MOM connectsto the server succesfully (otherwise, how can it know SPID?) The serveritself worked fine at that time - nothing unusual, all the jobsfinished succesfully including the heavy ones. What can block SELECTGETDATE() query for 6 minutes???
We have a situation that occurs every so often with blocking ofvarious databases on one server (Win200 SQL7). It appears to happen atrandom, so I'm assuming it originates from something a user does andnot a regularily run process.We've examined the data available to us and used the very helpfulblocking code on http://www.algonet.se/~sommar/sqlutil/aba_lockinfo.html(Thanks Erland).Were getting closer to finding the problem, but need some advice onwhat to look for.This is a bit of guesswork, but we suspect that we get into asituation where blocking takes places, and this then cascades to otherprocesses which then block others in turn. The original culprit thenfinishes, but the blocks continue as the newer processes are holdingsomething else up. A bit like dominoes. It seems to take a while tofree this up.The problem we have is determining the start of this process. Once weare made aware of blocking issues, we can find out who is doing what,but almost always get a different answer/user and think we're gettingto it a little late.Ideally, I want to log the blocking somewhere so I can examine thefiles when this occurs and can therefore establish a pattern etc...Any ideas or suggestions would be welcome.
SQL2K, sp3Active Server Pages front-endI am having a blocking problem with a spid executing a storedprocedure that does no updates. When I look at the locks the blockingspid has, some of them have lock mode "IS". Looking in BOL, I see "S"is shared, but I don't see "IS". Can anyone tell me what lock mode"IS" is?And how could a stored procedure that does no updates be guilty ofblocking?There are no cursors in it.Thanks!
I have a 3 simple packages get called from master package. First package populates time dimension (stored proc), second one populates transaction type dimension(stored proc) and the final one populates date dimension.
I set the TransactionOption = Required in the Master package, every thing else (package & component) set TransactionOption = Supported.
I have been testing transactions, basically I made time and transaction type dimension to fail and the package did roll back. I am stuck in the date dimension.
Within Date dimension I got a stored procedure which populates calendar date attributes into Wrk_Date table. Then I have a data flow task which reads from thats working table, but it cant access it. I tried running SP_WHO2 command, and the status is SUSPENDED, being blocked by id -2.
I saw someone had similar problem and I did read Ash's comments. I did try to change the isolation level, didnt help. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=74372&SiteID=1