Blocking And Return Parameters

Jul 20, 2005

Is it possible the existence of a return parameter on an SP running
insert statements would cause blocking to happen (any removing it
might help eliminate it?)
The SPs in question have three INSERT INTO statements using an
@@IDENTITY to help populate the second and third tables based on the
PK of the newly inserted record in the first INSERT INTO Statement.
I have recently stared to receive timeout errors in a multi-user
enviroment and wonder if that's part of the cause. In this
environment, users are requerying a table that is also being written
to. The writes are infrequent but the reads of that table are very
frequent.
On the read side I have added Select from TableX WITH (READPAST)...
On the write side I have elimnated the return parameters. I'm hoping
these two approaches help.
Help is greatly appreciated.
lq

View 6 Replies


ADVERTISEMENT

Return Blocking Information

May 5, 2008



Using the Process Info Page of Activity Monitor in SQL Server Management Studio, I can discover which Process ID has been Blocked another Process ID.

I need a scipt i can run to Find out what Query or procedure is actually causing the Blocking.

For example I run a SQL Statement to Insert records in to a Table, but it is blocked by another process runing a SQL Statement. How can i discover the specific SQL Statement that is causing the blocking.

What SQL Script or Method can i use to accomplish this Task. Thanks

I am using SQL Server 2005

View 1 Replies View Related

How Do I Return An Error Message If Certain Parameters Are Not Met?

May 14, 2008

I hope I'm posting this question in the proper forum, please pardon me if I am not. Here's my situation. I have an application written in VB.Net connecting to a SQL 2005 database. I have a stored procedure that is looking for duplicate entries of a "Company Name" prior to running the stored procedure. If there is no duplicate Company Name want the stored procedure to run, if there is a duplicate I want to return an error message alerting the user to the fact that the Company Name they are attempting to add already exists. I have my if statement but I'm not sure how to return an error message within this context. Any help would be greatly appreciated!

Many Thanks-



IF(SELECT COUNT(CompanyDimID) FROM dbo.CompanyDim WHERE CompanyName = @CompanyDim) = 0

BEGIN

.......................SQL query here................................

ELSE
(I want to return an error message in the ELSE portion to call out that we have a duplicate Company Name)

View 3 Replies View Related

How To Get Store Procedure's Return Value And Output Parameters From BLL?

Oct 10, 2007

ex:
myprocedure(@Cusname varchar(50), @Cusid int output)as
Insert into Customer(Cusname) values (@Cusname)SELECT @cusid = @@IDENTITY
 i add the query to my adapter called CreatCustomer (@Cusnam,@Cusid)private Merp_CusListTableAdapter _CuslistAdapter = null;protected Merp_CusListTableAdapter Adapter
{
get
{if (_CuslistAdapter == null)
_CuslistAdapter = new Merp_CusListTableAdapter();return _CuslistAdapter;
}
}
Now how i write function in BLL to receive output paramter from creatcustomer function?

View 1 Replies View Related

Stored Procedure With Parameters OUTPUT And RETURN VALUE

Oct 26, 2000

Hi

How I building a stored procedure that
return a output parameter and value return that I can
call from other stored procedure or VB ?

thank you in advance

View 1 Replies View Related

How Do You Write A Query To Return All Record With Parameters?

Jan 24, 2006

For example:

Select * From Customers Where CustomerName = "Tom" and CustomerLocation = @Location

I know MS Access you can use a "*" to retrieve all records when there is a parameter. What does SQL Sever query use to retrieve all record?

View 14 Replies View Related

SqlCommand Return And Output Parameters Not Working, But Input Does?

Feb 18, 2006

The foolowing code I cannot seem to get working right. There is an open connection c0 and a SqlCommand k0 persisting in class.The data in r0 is correct and gets the input arguments at r0=k0->ExecuteReader(), but nothing I do seems to get the output values. What am I missing about this?

System::Boolean rs::sp(System::String ^ ssp){

System::String ^ k0s0; bool bOK;

System::Data::SqlClient::SqlParameter ^ parami0;

System::Data::SqlClient::SqlParameter ^ parami1;

System::Data::SqlClient::SqlParameter ^ parami2;

System::Data::SqlClient::SqlParameter ^ paramz0;

System::Data::SqlClient::SqlParameter ^ paramz1;

System::Int32 pz0=0;System::Int32 pz1=0;

k0s = ssp;

k0->CommandType=System::Data::CommandType::StoredProcedure;

k0->CommandText=k0s;

paramz0=k0->Parameters->Add("@RETURN_VALUE", System::Data::SqlDbType::Int);

//paramz0=k0->Parameters->AddWithValue("@RETURN_VALUE",pz0);

//paramz0=k0->Parameters->AddWithValue("@RETURN_VALUE",pz0);

paramz0->Direction=System::Data::ParameterDirection::ReturnValue;

paramz0->DbType=System::Data::DbType::Int32;

parami0=k0->Parameters->AddWithValue("@DESCXV","chicken");

parami0->Direction=System::Data::ParameterDirection::Input;

parami1=k0->Parameters->AddWithValue("@SRCXV","UU");

parami1->Direction=System::Data::ParameterDirection::Input;

//paramz1=k0->Parameters->AddWithValue("@RCOUNT",pz1);

paramz1=k0->Parameters->Add("@RCOUNT",System::Data::SqlDbType::Int);

paramz1->Direction=System::Data::ParameterDirection::InputOutput;

paramz0->DbType=System::Data::DbType::Int32;

//k0->Parameters->GetParameter("@RCOUNT");

r0=k0->ExecuteReader();

//pz0=System::Convert::ToInt32(paramz0->SqlValue);

bOK=k0->Parameters->Contains("@RCOUNT");

//k0->Parameters->GetParameter("@RCOUNT");

pz0=System::Convert::ToInt32(paramz0->Value);

pz1=System::Convert::ToInt32(paramz1->Value);

ndx = -1;

while(r0->Read()){

if (ndx == -1){

ndx=0;

pai0ndx=0;

pad0ndx=0;

r0nf=r0->FieldCount::get();

for (iG1_20=0;iG1_20<r0nf;iG1_20++){

this->psf0[iG1_20]=this->r0->GetName(iG1_20);

this->psv0[iG1_20]=this->r0->GetDataTypeName(iG1_20);

this->psz0[iG1_20]=System::Convert::ToString(this->r0->GetValue(iG1_20));

this->pas0[ndx,iG1_20]=System::Convert::ToString(this->r0->GetValue(iG1_20));

if (psv0[iG1_20]=="int") {pai0[ndx,pai0ndx]=System::Convert::ToInt32(r0->GetValue(iG1_20));pai0ndx++;}

if (psv0[iG1_20]=="float") {pad0[ndx,pad0ndx]=System::Convert::ToDouble(r0->GetValue(iG1_20));pad0ndx++;}

}



}

else {

pai0ndx=0;

pad0ndx=0;

for (iG1_20=0;iG1_20<r0nf;iG1_20++)

{ this->pas0[ndx,iG1_20]=System::Convert::ToString(this->r0->GetValue(iG1_20));

if (psv0[iG1_20]=="int") {pai0[ndx,pai0ndx]=System::Convert::ToInt32(r0->GetValue(iG1_20));pai0ndx++;}

if (psv0[iG1_20]=="float") {pad0[ndx,pad0ndx]=System::Convert::ToDouble(r0->GetValue(iG1_20));pad0ndx++;}

}

}

ndx++;

}

r0nr=ndx;

r0->Close();

k0->Parameters->Remove(paramz0);

k0->Parameters->Remove(parami1);

k0->Parameters->Remove(parami0);

k0->Parameters->Remove(paramz1);

return true;

}

View 5 Replies View Related

Return Error Code (return Value) From A Stored Procedure Using A Sql Task

Feb 12, 2008


I have a package that I have been attempting to return a error code after the stored procedure executes, otherwise the package works great.

I call the stored procedure from a Execute SQL Task (execute Marketing_extract_history_load_test ?, ? OUTPUT)
The sql task rowset is set to NONE. It is a OLEB connection.

I have two parameters mapped:

tablename input varchar 0 (this variable is set earlier in a foreach loop) ADO.
returnvalue output long 1

I set the breakpoint and see the values change, but I have a OnFailure conditon set if it returns a failure. The failure is ignored and the package completes. No quite what I wanted.

The first part of the sp is below and I set the value @i and return.


CREATE procedure [dbo].[Marketing_extract_history_load_TEST]

@table_name varchar(200),

@i int output

as

Why is it not capturing and setting the error and execute my OnFailure code? I have tried setting one of my parameter mappings to returnvalue with no success.

View 2 Replies View Related

Blocking

Aug 15, 2000

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?

View 1 Replies View Related

Blocking

Nov 26, 2001

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.

View 1 Replies View Related

Self Blocking SP4

Nov 1, 2007

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 ?

thanks,
Paul

View 7 Replies View Related

Blocking When Doing Bcp

Jan 6, 2004

Any ideas?

I execute a sproc from QA.
It interogates a folder:


Select @Command_String = 'Dir ' + @FilePath + '*.txt'
Insert Into XLAT_Folder exec master..xp_cmdshell @Command_String
[/code[


Which I then Parse and get the details...

Set up a CURSOR (Booo hiss....)

[code]

DECLARE XLAT_Folder CURSOR FOR
SELECT Create_Time
, File_Size
, [File_Name]
FROM XLAT_Folder_Parsed
ORDER BY [File_Name]





WHILE FETCH STATUS = 0
BEGIN
BEGIN TRAN


Then, based on the methodology that the file name must match the table and format file (I check to make sure everything is out there)

I then bcp the data in using my connection pooling id (I'm logged on as sa in qa)



SET @cmd = 'bcp ' + @db_name + '..' + SUBSTRING(@File_Name,1,CHARINDEX('.',@File_Name)-1) + ' in '
+ @FilePathAndName
+ ' -f' + 'd:DataTax' + SUBSTRING(@File_Name,1,CHARINDEX('.',@File_Name)-1) + '.fmt'
+ ' -S' + @@servername + ' -U -P'

SET @Command_string = 'EXEC master..xp_cmdshell ''' + @cmd + '''' + ', NO_OUTPUT'

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...

When I do sp_who, it shows the blocking...

I'm so confused....

View 8 Replies View Related

Blocking

Aug 31, 2006

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

Thanks

View 2 Replies View Related

Blocking

Nov 13, 2007

Hi Gurus,

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.

Any Suggestions as to where to start.

Thx in Advance

Venu

View 13 Replies View Related

Blocking

Jul 23, 2005

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

View 4 Replies View Related

How To Return SqlDataReader And Return Value (page Count) From SPROC

Jan 2, 2006

This is my function, it returns SQLDataReader to DATALIST control. How
to return page number with the SQLDataReader set ? sql server 2005,
asp.net 2.0

    Function get_all_events() As SqlDataReader
        Dim myConnection As New
SqlConnection(ConfigurationManager.AppSettings("..........."))
        Dim myCommand As New SqlCommand("EVENTS_LIST_BY_REGION_ALL", myConnection)
        myCommand.CommandType = CommandType.StoredProcedure

        Dim parameterState As New SqlParameter("@State", SqlDbType.VarChar, 2)
        parameterState.Value = Request.Params("State")
        myCommand.Parameters.Add(parameterState)

        Dim parameterPagesize As New SqlParameter("@pagesize", SqlDbType.Int, 4)
        parameterPagesize.Value = 20
        myCommand.Parameters.Add(parameterPagesize)

        Dim parameterPagenum As New SqlParameter("@pageNum", SqlDbType.Int, 4)
        parameterPagenum.Value = pn1.SelectedPage
        myCommand.Parameters.Add(parameterPagenum)

        Dim parameterPageCount As New SqlParameter("@pagecount", SqlDbType.Int, 4)
        parameterPageCount.Direction = ParameterDirection.ReturnValue
        myCommand.Parameters.Add(parameterPageCount)

        myConnection.Open()
        'myCommand.ExecuteReader(CommandBehavior.CloseConnection)
        'pages = CType(myCommand.Parameters("@pagecount").Value, Integer)
        Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    End Function

Variable Pages is global integer.

This is what i am calling
        DataList1.DataSource = get_all_events()
        DataList1.DataBind()

How to return records and also the return value of pagecount ? i tried many options, nothing work. Please help !!. I am struck

View 3 Replies View Related

'Return' Statement In A Function,Get,or Operator Must Return A Value....Question

Aug 28, 2007


I'm a Reporting Services New-Be.

I'm trying to create a report that's based on a SQL-2005 Stored Procedure.

I added the Report Designer, a Report dataset ( based on a shared datasource).

When I try to build the project in BIDS, I get an error. The error occurs three times, once for each parameter on the stored procedure.

I'll only reproduce one instance of the error for the sake of brevity.

[rsCompilerErrorInExpression] The Value expression for the query parameter 'UserID' contains an error : [BC30654] 'Return' statement in a Function, Get, or Operator must return a value.

I've searched on this error and it looks like it's a Visual Basic error :

http://msdn2.microsoft.com/en-us/library/8x403818(VS.80).aspx

My guess is that BIDS is creating some VB code behind the scenes for the report.

I can't find any other information that seems to fit this error.

The other reports in the BIDS project built successfully before I added this report, so it must be something specific to the report.

BTW, the Stored Procedure this report is based on a global temp table. The other reports do not use temp tables.

Can anyone help ?

Thanks,

View 5 Replies View Related

Sql Blocking Problem

Dec 13, 2007

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

View 6 Replies View Related

Blocking URGENT!!

Jan 14, 2002

Hi ALL!
Can a sleeping process block another process sleeping/runnable?It's happening in our SQL server.Can someone expalin??
thanks.
Di.

View 1 Replies View Related

SQL Server 7 Blocking

Apr 24, 2002

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?

Thanks in advance for any suggestions...
-Raj

View 1 Replies View Related

Blocking Processes

May 29, 2001

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.

View 2 Replies View Related

Blocking (Urgent)

Jul 10, 2001

Hello,

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?

Thanks

View 2 Replies View Related

Blocking (Urgent)

Jul 13, 2001

Hello,

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?

wht should we do to monitor locks?

Thanks

Binoy

View 2 Replies View Related

Spid - Blocking

Nov 15, 2000

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?

Thanks

View 2 Replies View Related

Blocking Problem.

Feb 4, 2001

Hi there,

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.

Appreciated, If anyone out there advice on this.

Many thanks in advance.

Sindi

View 1 Replies View Related

Blocking Problem

Apr 19, 2000

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??

Thanks
David

View 3 Replies View Related

Blocked/Blocking

Dec 7, 1999

Hello...

Is it normal in SQL Server 6.5 the user who only running the query blocking the other user who try to update/add the records?

note: The query is a complex SQL.

Many Thanks!

View 2 Replies View Related

Insert Blocking...

Jun 2, 2005

found many blocking on SQL2000 enterprise by insert statement, the same insert statement failed in the sql/w with violation on the primary key.

however, the appl insert also got the same error from log, but still in 'blocking' instead of to be 'killed' by the pk violation.

what would be the options to deal with this issue?

thanks
-D

View 5 Replies View Related

Blocking Issue

Nov 17, 2005

Please advice.

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.

Help appreciated

View 3 Replies View Related

Blocking Problem

Aug 24, 2001

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

View 2 Replies View Related

Blocking Sa User

Dec 8, 2006

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.


Regards,
Anand

View 8 Replies View Related

Odd Blocking Issue

Sep 4, 2007

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

set @NumDeleted=@NumDeleted + @@ROWCOUNT

View 3 Replies View Related

Blocking And Transactions OK?

Sep 23, 2005

I'm wondering if I'm doing this right. Wondering about the transactionsand error handling. (Do I even need to put BEGIN TRANSACTION ANDCOMMIT TRANSACTION in there?)I think that this sproc is causing occasional blocking:Alter Procedure sprocINSERTSTUFF@Col1Data int = Null,@Col2Data nvarchar(255) = Null,@Col3Data ntext = Null,@UniqueID int OUTPUTASset nocount onset xact_abort onDECLARE @err intDECLARE @ServerDate DateTimeSELECT @ServerDate = GETUTCDATE()BEGIN TRANSACTIONINSERT INTOtblStuff (Col1, Col2, Col3, DateCreated, etc.)VALUES(@Col1Data, @Col2Data, @Col3Data, @ServerDate, etc.)SELECT @err = @@error IF @err <> 0 BEGIN ROLLBACK TRANSACTION RETURN@err ENDSELECT @UniqueID = SCOPE_IDENTITY()COMMIT TRANSACTIONBEGIN TRANSACTIONINSERT INTOtblMoreStuff (UniqueID, DateCreated, Col1, Col2, Col3)Values(@UniqueID, @ServerDate, @Col1Data, @Col2Data, 'Text Label: ' +isnull(Cast(@Col3Data AS nvarchar(4000)),'<none>')SELECT @err = @@error IF @err <> 0 BEGIN ROLLBACK TRANSACTION RETURN@err ENDCOMMIT TRANSACTIONSELECT @err = @@error IF @err <> 0 RETURN @err

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved