Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, March 29, 2012

about activeX script error in ssis package in SQL server 2005

when i run activex Script it's shows this error

[ActiveX Script Task] Error: Retrieving the file name for a component failed with error code 0x001B6438

Moving from .NET Framework Data Access and Storage...|||So is there a solution to this?
I've had a similar error when using the "scripting.filesystemobject" from within a script task in ssis.

about activeX script error in ssis package in SQL server 2005

when i run activex Script it's shows this error

[ActiveX Script Task] Error: Retrieving the file name for a component failed with error code 0x001B6438

Moving from .NET Framework Data Access and Storage...|||So is there a solution to this?
I've had a similar error when using the "scripting.filesystemobject" from within a script task in ssis.

about accessing SQL Server2005 database file from a remote computer

hi every one. i am a new user of asp.net 2.0 using C# code and i am facing a problem in accessing a SQL Server2005 database file in the remote computer. i have connected two pc with peer to peer connection and trying to add a databse using the "Add connection" option from the visual studio 2005. in the add connection dialog box it is showing me the remote server and it was supposed to show all the database in that SQL Server when i select one. but when i am choosing the server name it was not showing me anything. by the way i have configuered the surface area for "both TCP/IP and named pipes" and both the pc's server browser is turned on. is it the right way to access a database file from a remote pc or not?? please send me a good solution to do this things and try to explain the codes with example. waiting for response...plz send me the solution.. as soon as possible

Hi,

Try the following KB article, it may be helpful to you.

http://support.microsoft.com/kb/316649

Thanks.

|||

Hi,

SQL Server 2005 is not allowing remote connections by default. You have to configure the SQL Server 2005 for remote connections using SQL Server Surface Area Configuration tool.

If you refer to article athttp://www.kodyaz.com/content/SQLServerdoesnotallowremoteconnections.aspx , you may see how you can use this tool for allowing remote connections for a sql server instance.

Eralper

sql

Tuesday, March 27, 2012

abort insertcommand

hey.

I have a formview - inertitemtemplate. In here I have a button with CommandName="Insert". In code behind under FormView1.ItemInserting I want to be able to abort the inserting in some cases. Is this possible?

Simple. In the event, simply do: e.Cancel = true.

Tuesday, March 20, 2012

a trigger code

I have table T1 and I am trying to extract some date from T1 table based on inserts, updates and deletes. The destination table T2 has three fields F1, F2, F3, so I need something like

Insert into T2 (F1, F2, F3)

Select (F1, F2,Type)

From T1

Type should be defined based on Insert, Update, or Delete. This will be my first trigger, Can anyone write this trigger for me?

If you want to determine type of trigger action from single trigger then see code below:

set nocount on
go
if object_id('tr_tbl') is not null
drop table tr_tbl
go
create table tr_tbl(i int)
go
create trigger tr_test on tr_tbl for insert, update, delete as
if exists(select * from inserted) and exists(select * from deleted)
print 'Update...' -- set @.type = 'U'
else
if exists(select * from inserted)
print 'Insert...' -- set @.type = 'I'
else
print 'Delete...' -- set @.type = 'D'

... your code
go

insert tr_tbl values(1)
update tr_tbl set i = i + 1
delete tr_tbl

go

drop table tr_tbl

go

But it might be easier writing separate triggers. And you shouldn't query the base table T1 directly since you will get all rows in the table and not just the rows affected by the DML. You need to use the inserted/deleted tables based on the trigger action.

|||

This helps a lot, thanks,

One question: since there are more than one user on the system will there be a case that insert virtual table might have more than one row?

|||Yes, you should always write your trigger code such that it handles multiple rows. This will also force you to use simple set of DMLs from trigger for the logic which is more efficient than a procedural approach. If you want to enforce only singleton operations via DML then you can do so within trigger by checking for @.@.ROWCOUNT and rolling back the transaction/ DML operation.sql

a trigger code

I have table T1 and I am trying to extract some date from T1 table based on inserts, updates and deletes. The destination table T2 has three fields F1, F2, F3, so I need something like

Insert into T2 (F1, F2, F3)

Select (F1, F2,Type)

From T1

Type should be defined based on Insert, Update, or Delete. This will be my first trigger, Can anyone write this trigger for me?

you already have the code you need. you just need to put it in a trigger for which the syntax can be found in BOL.

A tricky code problem!

I have a report that looks like the following:

record record record null null record record
supress supress supress null record1 null supress
supress supress supress record2 null null supress

This is the best way to describe my data, its 3 rows of records and I want to show record1 and record2 on the top row. I have the other data beneath supressed. I am sure this maybe be possible using SQL code or using a loop or something but I have no idea where to start and have been trawling the web for answers or some code samples but have found none to date as it is quite a specific thing. Its tricky I know but could someone help me please?Hi,
I want to make a page break after section3 in crystal report(ver. 8) after displaying 5 records. I'm using .Dsr report. I am using the following code.

'*******************************
Set Report = New CrystalReport1
Report.Database.AddADOCommand db, cmd
For i = 1 To rs.Recordcount

Set txtObj = Report.Section2.AddTextObject(l, 150, vHight)
txtObj.Width = 300
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

Set txtObj = Report.Section2.AddTextObject(rs!ITEM_DESC, 400, vHight)
txtObj.Width = 2000
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

Set txtObj = Report.Section2.AddTextObject(rs!narmst_sItemName, 2800, vHight)
txtObj.Width = 1200
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

Set txtObj = Report.Section2.AddTextObject(rs!dlnsp_dItemRate, 4200, vHight)
txtObj.Width = 1200
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

Set txtObj = Report.Section2.AddTextObject(rs!dlnsp_dItemQty, 5700, vHight)
txtObj.Width = 1200
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

Set txtObj = Report.Section2.AddTextObject(rs!dlnsp_dItemRate * rs!dlnsp_dItemQty, 7100, vHight)
txtObj.Width = 1200
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

Set txtObj = Report.Section2.AddTextObject(rs!dlnsp_dItemRate * rs!dlnsp_dItemQty, 8500, vHight)
txtObj.Width = 1200
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

If IsNull(rs!VAT_AMT) Then
m = 0
Else
m = Val(rs!VAT_AMT)
End If

Set txtObj = Report.Section2.AddTextObject(m, 9600, vHight)
txtObj.Width = 1200
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

Set txtObj = Report.Section2.AddTextObject(Val(rs!dlnsp_dItemRate * rs!dlnsp_dItemQty + m), 11200, vHight)
txtObj.Width = 1200
txtObj.HorAlignment = crLeftAlign
txtObj.Font.Bold = True

If i > 5 Then
Report.Section3.NewPageAfter = True
End If

rs.MoveNext
vHight = vHight + 250
l = l + 1
Next i
'**************************

But it is not working. Please Help me.

with regards,
Arindam

Monday, March 19, 2012

A strange problem with SQL query fro getting field names

Hello All,

I have been trying to get this code work, but I could not. Every thing seems going well. However, The result of running the sql query is strange. It shows the field names twice.
Eg:) if you have a table called "newtable" that has two fields[Custnumber, Custname], you will get somthing like this [Custnumber, Custname Custnumber, Custname]. I have tried many times, but I couldn't fix it.

Sub Page_Load(sender As Object, e As EventArgs) handles Mybase.Load

if not page.Ispostback then

try
Sqlconnection = New Sqlconnection (connectionString)

querystring = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNs
WHERE TABLE_NAME = 'Newtable'"

SqlCommand = New SqlCommand(queryString, Sqlconnection)

SqlConnection.Open

dataReader = SqlCommand.ExecuteReader(CommandBehavior.CloseConnection)

while dataReader.Read()

Tablefields_txt.text += dataReader.Getstring(0) & ", "

End while

catch ex as Exception

msgbox("An error has occured: " + ex.Message,0, "Error Message")

finally

SqlConnection.Close()

End try
End if

Any help , pleaseCheck this bit. I assume this might have an impact on your problem.

Tablefields_txt.text += dataReader.Getstring(0) & ", "|||I have tried this:
Dim temp as string
while dataReader.Read()

temp += dataReader.Getstring(0) & ", "

End while

Tablefields_txt.text = temp

I think the problem might be from the querystring "select ....." , but i do know how to deal with it . I need help|||As I posted in your other thread, the problem is due to the "handles Mybase.Load". Remove this and you should see the results you expect.

Terri

Tuesday, March 6, 2012

A request to establish a connection with transaction manager denie

A user has reported the message "A request to establish a connection with the
transaction manager was denied". The code is at this point attempting to
START a transaction. So far I have been unable to duplicate this, though the
user has been able to get through this code in the past. Of course, no known
changes.
What causes this particular message?
--
Brad AshforthHi Brad
This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
you already have the maximum number of connections.
John
"Brad Ashforth" wrote:
> A user has reported the message "A request to establish a connection with the
> transaction manager was denied". The code is at this point attempting to
> START a transaction. So far I have been unable to duplicate this, though the
> user has been able to get through this code in the past. Of course, no known
> changes.
> What causes this particular message?
> --
> Brad Ashforth|||Hi John ... by "maximum # of connections", is this at the SERVER or CLIENT
level? Our application is designed such that we do not make use of nested
transactions. We have a "transaction" routine that is called with either
"Begin", "Commit" or "Rollback", and if the routine is called with "Begin"
(as it was in this case), we first execute a commit (in case a transaction is
pending that was not committed or rolled back) and then do the BEGIN. Of
course, if when we issue the commit if there is no pending transaction, we
get an error ... but that is trapped for and ignored if we are trying to
begin a new transaction.
So, that said ... there should only be one transaction active for the
application at any given time and if by chance we try to start another one
the code automatically commits the first one before starting the 2nd one.
Is there a way to query how many connections there are?
--
Brad Ashforth
"John Bell" wrote:
> Hi Brad
> This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
> you already have the maximum number of connections.
> John
> "Brad Ashforth" wrote:
> > A user has reported the message "A request to establish a connection with the
> > transaction manager was denied". The code is at this point attempting to
> > START a transaction. So far I have been unable to duplicate this, though the
> > user has been able to get through this code in the past. Of course, no known
> > changes.
> >
> > What causes this particular message?
> > --
> > Brad Ashforth|||Hi Brad,
Thank you for your posting!
I would like to know some detailed information:
1. Does your customer use Distribute Transaction? If so, does the DTC
services start?
2. Are there any error log in event log? If so, please post it here.
3. What's the SQL Server Version and the Server OS version?
Please let me know the result and so that I can provide further assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi Wei ... thank you.
1). No, the customer does not use Distributed Transactions (at least not to
their knowledge)
2) No errors in any of the event logs on the SQL Server box
3) From SQL Query Analyzer @.@.Version returns 8.00.760, from a cmd shell VER
returns 5.2.3790 (Windows Server 2003 Enterprise Edition)
Please note that this error occurred in an acceptance testing phase, not in
production.
--
Brad Ashforth
"Wei Lu [MSFT]" wrote:
> Hi Brad,
> Thank you for your posting!
> I would like to know some detailed information:
> 1. Does your customer use Distribute Transaction? If so, does the DTC
> services start?
> 2. Are there any error log in event log? If so, please post it here.
> 3. What's the SQL Server Version and the Server OS version?
> Please let me know the result and so that I can provide further assistance.
> Sincerely,
> Wei Lu
> Microsoft Online Community Support
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>|||Hi Brad
Checking @.@.TRANCOUNT will tell you whether a transaction is in progress.
Using a commit that when a transaction has not begun will cause an error:
Server: Msg 3902, Level 16, State 1, Line 1
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
Which you can easily avoid.
I don't think this is the cause of the issue! Do you reference any other
databases either in your stored procedures or triggers? Are you using
multipart naming conventions? Are you enquoting your names using square
braces []?
John
"Brad Ashforth" wrote:
> Hi John ... by "maximum # of connections", is this at the SERVER or CLIENT
> level? Our application is designed such that we do not make use of nested
> transactions. We have a "transaction" routine that is called with either
> "Begin", "Commit" or "Rollback", and if the routine is called with "Begin"
> (as it was in this case), we first execute a commit (in case a transaction is
> pending that was not committed or rolled back) and then do the BEGIN. Of
> course, if when we issue the commit if there is no pending transaction, we
> get an error ... but that is trapped for and ignored if we are trying to
> begin a new transaction.
> So, that said ... there should only be one transaction active for the
> application at any given time and if by chance we try to start another one
> the code automatically commits the first one before starting the 2nd one.
> Is there a way to query how many connections there are?
> --
> Brad Ashforth
>
> "John Bell" wrote:
> > Hi Brad
> >
> > This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
> > you already have the maximum number of connections.
> >
> > John
> >
> > "Brad Ashforth" wrote:
> >
> > > A user has reported the message "A request to establish a connection with the
> > > transaction manager was denied". The code is at this point attempting to
> > > START a transaction. So far I have been unable to duplicate this, though the
> > > user has been able to get through this code in the past. Of course, no known
> > > changes.
> > >
> > > What causes this particular message?
> > > --
> > > Brad Ashforth|||Hi John. Thank you.
We had not known about @.@.TRANCOUNT and agree that it makes more sense to
check this instead of trapping for a known error that is likely to occur (on
the other hand, isn't that what TRY/CATCH is supposed to do?) Anyway, I also
agree that this is not the likely cause of the error I originally posted a
question about.
We do not reference other databases, and in most (99%?) cases do not use
fully qualified table names. This is because most tables are in the DBO
schema and do not get to the user's own schema ... each user temp table (for
reports, etc) are in their own schema. In most cases the object names follow
standard conventions and should not need braces. This is also not an error
that is easily repeatable. It has been seen before but have had trouble
duplicating it.
Thanks,
Brad
--
Brad Ashforth
"John Bell" wrote:
> Hi Brad
> Checking @.@.TRANCOUNT will tell you whether a transaction is in progress.
> Using a commit that when a transaction has not begun will cause an error:
> Server: Msg 3902, Level 16, State 1, Line 1
> The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
> Which you can easily avoid.
> I don't think this is the cause of the issue! Do you reference any other
> databases either in your stored procedures or triggers? Are you using
> multipart naming conventions? Are you enquoting your names using square
> braces []?
>
> John
> "Brad Ashforth" wrote:
> > Hi John ... by "maximum # of connections", is this at the SERVER or CLIENT
> > level? Our application is designed such that we do not make use of nested
> > transactions. We have a "transaction" routine that is called with either
> > "Begin", "Commit" or "Rollback", and if the routine is called with "Begin"
> > (as it was in this case), we first execute a commit (in case a transaction is
> > pending that was not committed or rolled back) and then do the BEGIN. Of
> > course, if when we issue the commit if there is no pending transaction, we
> > get an error ... but that is trapped for and ignored if we are trying to
> > begin a new transaction.
> >
> > So, that said ... there should only be one transaction active for the
> > application at any given time and if by chance we try to start another one
> > the code automatically commits the first one before starting the 2nd one.
> >
> > Is there a way to query how many connections there are?
> > --
> > Brad Ashforth
> >
> >
> > "John Bell" wrote:
> >
> > > Hi Brad
> > >
> > > This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
> > > you already have the maximum number of connections.
> > >
> > > John
> > >
> > > "Brad Ashforth" wrote:
> > >
> > > > A user has reported the message "A request to establish a connection with the
> > > > transaction manager was denied". The code is at this point attempting to
> > > > START a transaction. So far I have been unable to duplicate this, though the
> > > > user has been able to get through this code in the past. Of course, no known
> > > > changes.
> > > >
> > > > What causes this particular message?
> > > > --
> > > > Brad Ashforth|||Hi Brad
Prefixing with the schema name should improve performance and caching.
If this problem is periodic you are not going to know for certain that you
have cured it!! How often does it occur? Does it mainly occur after a re-boot
or a high load levels? I know you have checked the Event logs what about the
SQL Server log?
If MSDTC is currently running try switching it off, as this should not
effect your application if it is not being used!!
John
"Brad Ashforth" wrote:
> Hi John. Thank you.
> We had not known about @.@.TRANCOUNT and agree that it makes more sense to
> check this instead of trapping for a known error that is likely to occur (on
> the other hand, isn't that what TRY/CATCH is supposed to do?) Anyway, I also
> agree that this is not the likely cause of the error I originally posted a
> question about.
> We do not reference other databases, and in most (99%?) cases do not use
> fully qualified table names. This is because most tables are in the DBO
> schema and do not get to the user's own schema ... each user temp table (for
> reports, etc) are in their own schema. In most cases the object names follow
> standard conventions and should not need braces. This is also not an error
> that is easily repeatable. It has been seen before but have had trouble
> duplicating it.
> Thanks,
> Brad
> --
> Brad Ashforth
>
> "John Bell" wrote:
> > Hi Brad
> >
> > Checking @.@.TRANCOUNT will tell you whether a transaction is in progress.
> > Using a commit that when a transaction has not begun will cause an error:
> >
> > Server: Msg 3902, Level 16, State 1, Line 1
> > The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
> >
> > Which you can easily avoid.
> >
> > I don't think this is the cause of the issue! Do you reference any other
> > databases either in your stored procedures or triggers? Are you using
> > multipart naming conventions? Are you enquoting your names using square
> > braces []?
> >
> >
> > John
> >
> > "Brad Ashforth" wrote:
> >
> > > Hi John ... by "maximum # of connections", is this at the SERVER or CLIENT
> > > level? Our application is designed such that we do not make use of nested
> > > transactions. We have a "transaction" routine that is called with either
> > > "Begin", "Commit" or "Rollback", and if the routine is called with "Begin"
> > > (as it was in this case), we first execute a commit (in case a transaction is
> > > pending that was not committed or rolled back) and then do the BEGIN. Of
> > > course, if when we issue the commit if there is no pending transaction, we
> > > get an error ... but that is trapped for and ignored if we are trying to
> > > begin a new transaction.
> > >
> > > So, that said ... there should only be one transaction active for the
> > > application at any given time and if by chance we try to start another one
> > > the code automatically commits the first one before starting the 2nd one.
> > >
> > > Is there a way to query how many connections there are?
> > > --
> > > Brad Ashforth
> > >
> > >
> > > "John Bell" wrote:
> > >
> > > > Hi Brad
> > > >
> > > > This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
> > > > you already have the maximum number of connections.
> > > >
> > > > John
> > > >
> > > > "Brad Ashforth" wrote:
> > > >
> > > > > A user has reported the message "A request to establish a connection with the
> > > > > transaction manager was denied". The code is at this point attempting to
> > > > > START a transaction. So far I have been unable to duplicate this, though the
> > > > > user has been able to get through this code in the past. Of course, no known
> > > > > changes.
> > > > >
> > > > > What causes this particular message?
> > > > > --
> > > > > Brad Ashforth|||Hi John .. Thank you.
As the application is used in multiple environments, we have no control or
knowledge of the deployment and don't code the fully qualified object name,
currently it would take a LOT of rework to do this. Is the performance
improvement enough to make it worthwhile?
Yes, periodic failures are a pain to diagnose. The problem occurs RARELY (I
think it has only happened once or twice in a deployment. Not all deployments
have seen the problem and the total number of occurrences is certainly less
than 6 or 7. Rebooting does not seem to be the issue, nor does load level (no
reboots either before or after the error). I currently do not have access to
the SQL Server log. Will try to obtain it.
MSDTC is not used by our application, but if a deployment decides to house
multiple databases on the SQLServer, wouldn't it be better to leave it on?
--
Brad Ashforth
"John Bell" wrote:
> Hi Brad
> Prefixing with the schema name should improve performance and caching.
> If this problem is periodic you are not going to know for certain that you
> have cured it!! How often does it occur? Does it mainly occur after a re-boot
> or a high load levels? I know you have checked the Event logs what about the
> SQL Server log?
> If MSDTC is currently running try switching it off, as this should not
> effect your application if it is not being used!!
> John
>
>
> "Brad Ashforth" wrote:
> > Hi John. Thank you.
> >
> > We had not known about @.@.TRANCOUNT and agree that it makes more sense to
> > check this instead of trapping for a known error that is likely to occur (on
> > the other hand, isn't that what TRY/CATCH is supposed to do?) Anyway, I also
> > agree that this is not the likely cause of the error I originally posted a
> > question about.
> >
> > We do not reference other databases, and in most (99%?) cases do not use
> > fully qualified table names. This is because most tables are in the DBO
> > schema and do not get to the user's own schema ... each user temp table (for
> > reports, etc) are in their own schema. In most cases the object names follow
> > standard conventions and should not need braces. This is also not an error
> > that is easily repeatable. It has been seen before but have had trouble
> > duplicating it.
> >
> > Thanks,
> > Brad
> > --
> > Brad Ashforth
> >
> >
> > "John Bell" wrote:
> >
> > > Hi Brad
> > >
> > > Checking @.@.TRANCOUNT will tell you whether a transaction is in progress.
> > > Using a commit that when a transaction has not begun will cause an error:
> > >
> > > Server: Msg 3902, Level 16, State 1, Line 1
> > > The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
> > >
> > > Which you can easily avoid.
> > >
> > > I don't think this is the cause of the issue! Do you reference any other
> > > databases either in your stored procedures or triggers? Are you using
> > > multipart naming conventions? Are you enquoting your names using square
> > > braces []?
> > >
> > >
> > > John
> > >
> > > "Brad Ashforth" wrote:
> > >
> > > > Hi John ... by "maximum # of connections", is this at the SERVER or CLIENT
> > > > level? Our application is designed such that we do not make use of nested
> > > > transactions. We have a "transaction" routine that is called with either
> > > > "Begin", "Commit" or "Rollback", and if the routine is called with "Begin"
> > > > (as it was in this case), we first execute a commit (in case a transaction is
> > > > pending that was not committed or rolled back) and then do the BEGIN. Of
> > > > course, if when we issue the commit if there is no pending transaction, we
> > > > get an error ... but that is trapped for and ignored if we are trying to
> > > > begin a new transaction.
> > > >
> > > > So, that said ... there should only be one transaction active for the
> > > > application at any given time and if by chance we try to start another one
> > > > the code automatically commits the first one before starting the 2nd one.
> > > >
> > > > Is there a way to query how many connections there are?
> > > > --
> > > > Brad Ashforth
> > > >
> > > >
> > > > "John Bell" wrote:
> > > >
> > > > > Hi Brad
> > > > >
> > > > > This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
> > > > > you already have the maximum number of connections.
> > > > >
> > > > > John
> > > > >
> > > > > "Brad Ashforth" wrote:
> > > > >
> > > > > > A user has reported the message "A request to establish a connection with the
> > > > > > transaction manager was denied". The code is at this point attempting to
> > > > > > START a transaction. So far I have been unable to duplicate this, though the
> > > > > > user has been able to get through this code in the past. Of course, no known
> > > > > > changes.
> > > > > >
> > > > > > What causes this particular message?
> > > > > > --
> > > > > > Brad Ashforth|||Hi Brad
Using the schema name should not effect the deployments as this should be
constant, two part naming will help to varying degrees, depending on what
specification the server has and the load it takes. In general it is good
practice to do this and is usually easier to implement though of coding
standards and QA than retrospectively.
If you share the server with other applications you would need to make sure
that they don't use MSDTC, but any service on the server that is not being
used should be stopped as they will take up resources. If you stop this
service then it may make it easier to highlight something wrong with your own
application.
John
"Brad Ashforth" wrote:
> Hi John .. Thank you.
> As the application is used in multiple environments, we have no control or
> knowledge of the deployment and don't code the fully qualified object name,
> currently it would take a LOT of rework to do this. Is the performance
> improvement enough to make it worthwhile?
> Yes, periodic failures are a pain to diagnose. The problem occurs RARELY (I
> think it has only happened once or twice in a deployment. Not all deployments
> have seen the problem and the total number of occurrences is certainly less
> than 6 or 7. Rebooting does not seem to be the issue, nor does load level (no
> reboots either before or after the error). I currently do not have access to
> the SQL Server log. Will try to obtain it.
> MSDTC is not used by our application, but if a deployment decides to house
> multiple databases on the SQLServer, wouldn't it be better to leave it on?
> --
> Brad Ashforth
>
> "John Bell" wrote:
> > Hi Brad
> >
> > Prefixing with the schema name should improve performance and caching.
> >
> > If this problem is periodic you are not going to know for certain that you
> > have cured it!! How often does it occur? Does it mainly occur after a re-boot
> > or a high load levels? I know you have checked the Event logs what about the
> > SQL Server log?
> >
> > If MSDTC is currently running try switching it off, as this should not
> > effect your application if it is not being used!!
> >
> > John
> >
> >
> >
> >
> >
> > "Brad Ashforth" wrote:
> >
> > > Hi John. Thank you.
> > >
> > > We had not known about @.@.TRANCOUNT and agree that it makes more sense to
> > > check this instead of trapping for a known error that is likely to occur (on
> > > the other hand, isn't that what TRY/CATCH is supposed to do?) Anyway, I also
> > > agree that this is not the likely cause of the error I originally posted a
> > > question about.
> > >
> > > We do not reference other databases, and in most (99%?) cases do not use
> > > fully qualified table names. This is because most tables are in the DBO
> > > schema and do not get to the user's own schema ... each user temp table (for
> > > reports, etc) are in their own schema. In most cases the object names follow
> > > standard conventions and should not need braces. This is also not an error
> > > that is easily repeatable. It has been seen before but have had trouble
> > > duplicating it.
> > >
> > > Thanks,
> > > Brad
> > > --
> > > Brad Ashforth
> > >
> > >
> > > "John Bell" wrote:
> > >
> > > > Hi Brad
> > > >
> > > > Checking @.@.TRANCOUNT will tell you whether a transaction is in progress.
> > > > Using a commit that when a transaction has not begun will cause an error:
> > > >
> > > > Server: Msg 3902, Level 16, State 1, Line 1
> > > > The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
> > > >
> > > > Which you can easily avoid.
> > > >
> > > > I don't think this is the cause of the issue! Do you reference any other
> > > > databases either in your stored procedures or triggers? Are you using
> > > > multipart naming conventions? Are you enquoting your names using square
> > > > braces []?
> > > >
> > > >
> > > > John
> > > >
> > > > "Brad Ashforth" wrote:
> > > >
> > > > > Hi John ... by "maximum # of connections", is this at the SERVER or CLIENT
> > > > > level? Our application is designed such that we do not make use of nested
> > > > > transactions. We have a "transaction" routine that is called with either
> > > > > "Begin", "Commit" or "Rollback", and if the routine is called with "Begin"
> > > > > (as it was in this case), we first execute a commit (in case a transaction is
> > > > > pending that was not committed or rolled back) and then do the BEGIN. Of
> > > > > course, if when we issue the commit if there is no pending transaction, we
> > > > > get an error ... but that is trapped for and ignored if we are trying to
> > > > > begin a new transaction.
> > > > >
> > > > > So, that said ... there should only be one transaction active for the
> > > > > application at any given time and if by chance we try to start another one
> > > > > the code automatically commits the first one before starting the 2nd one.
> > > > >
> > > > > Is there a way to query how many connections there are?
> > > > > --
> > > > > Brad Ashforth
> > > > >
> > > > >
> > > > > "John Bell" wrote:
> > > > >
> > > > > > Hi Brad
> > > > > >
> > > > > > This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
> > > > > > you already have the maximum number of connections.
> > > > > >
> > > > > > John
> > > > > >
> > > > > > "Brad Ashforth" wrote:
> > > > > >
> > > > > > > A user has reported the message "A request to establish a connection with the
> > > > > > > transaction manager was denied". The code is at this point attempting to
> > > > > > > START a transaction. So far I have been unable to duplicate this, though the
> > > > > > > user has been able to get through this code in the past. Of course, no known
> > > > > > > changes.
> > > > > > >
> > > > > > > What causes this particular message?
> > > > > > > --
> > > > > > > Brad Ashforth|||Hi John, Thank you ... I found that the test server does NOT host other
databases that require MSDTC but the server DID have the service as auto
start. I've set it to manual and stopped the service. We'll keep checking to
see if it happens again.
Thank you,
Brad Ashforth
"John Bell" wrote:
> Hi Brad
> Using the schema name should not effect the deployments as this should be
> constant, two part naming will help to varying degrees, depending on what
> specification the server has and the load it takes. In general it is good
> practice to do this and is usually easier to implement though of coding
> standards and QA than retrospectively.
> If you share the server with other applications you would need to make sure
> that they don't use MSDTC, but any service on the server that is not being
> used should be stopped as they will take up resources. If you stop this
> service then it may make it easier to highlight something wrong with your own
> application.
> John
>
> "Brad Ashforth" wrote:
> > Hi John .. Thank you.
> >
> > As the application is used in multiple environments, we have no control or
> > knowledge of the deployment and don't code the fully qualified object name,
> > currently it would take a LOT of rework to do this. Is the performance
> > improvement enough to make it worthwhile?
> >
> > Yes, periodic failures are a pain to diagnose. The problem occurs RARELY (I
> > think it has only happened once or twice in a deployment. Not all deployments
> > have seen the problem and the total number of occurrences is certainly less
> > than 6 or 7. Rebooting does not seem to be the issue, nor does load level (no
> > reboots either before or after the error). I currently do not have access to
> > the SQL Server log. Will try to obtain it.
> >
> > MSDTC is not used by our application, but if a deployment decides to house
> > multiple databases on the SQLServer, wouldn't it be better to leave it on?
> >
> > --
> > Brad Ashforth
> >
> >
> > "John Bell" wrote:
> >
> > > Hi Brad
> > >
> > > Prefixing with the schema name should improve performance and caching.
> > >
> > > If this problem is periodic you are not going to know for certain that you
> > > have cured it!! How often does it occur? Does it mainly occur after a re-boot
> > > or a high load levels? I know you have checked the Event logs what about the
> > > SQL Server log?
> > >
> > > If MSDTC is currently running try switching it off, as this should not
> > > effect your application if it is not being used!!
> > >
> > > John
> > >
> > >
> > >
> > >
> > >
> > > "Brad Ashforth" wrote:
> > >
> > > > Hi John. Thank you.
> > > >
> > > > We had not known about @.@.TRANCOUNT and agree that it makes more sense to
> > > > check this instead of trapping for a known error that is likely to occur (on
> > > > the other hand, isn't that what TRY/CATCH is supposed to do?) Anyway, I also
> > > > agree that this is not the likely cause of the error I originally posted a
> > > > question about.
> > > >
> > > > We do not reference other databases, and in most (99%?) cases do not use
> > > > fully qualified table names. This is because most tables are in the DBO
> > > > schema and do not get to the user's own schema ... each user temp table (for
> > > > reports, etc) are in their own schema. In most cases the object names follow
> > > > standard conventions and should not need braces. This is also not an error
> > > > that is easily repeatable. It has been seen before but have had trouble
> > > > duplicating it.
> > > >
> > > > Thanks,
> > > > Brad
> > > > --
> > > > Brad Ashforth
> > > >
> > > >
> > > > "John Bell" wrote:
> > > >
> > > > > Hi Brad
> > > > >
> > > > > Checking @.@.TRANCOUNT will tell you whether a transaction is in progress.
> > > > > Using a commit that when a transaction has not begun will cause an error:
> > > > >
> > > > > Server: Msg 3902, Level 16, State 1, Line 1
> > > > > The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
> > > > >
> > > > > Which you can easily avoid.
> > > > >
> > > > > I don't think this is the cause of the issue! Do you reference any other
> > > > > databases either in your stored procedures or triggers? Are you using
> > > > > multipart naming conventions? Are you enquoting your names using square
> > > > > braces []?
> > > > >
> > > > >
> > > > > John
> > > > >
> > > > > "Brad Ashforth" wrote:
> > > > >
> > > > > > Hi John ... by "maximum # of connections", is this at the SERVER or CLIENT
> > > > > > level? Our application is designed such that we do not make use of nested
> > > > > > transactions. We have a "transaction" routine that is called with either
> > > > > > "Begin", "Commit" or "Rollback", and if the routine is called with "Begin"
> > > > > > (as it was in this case), we first execute a commit (in case a transaction is
> > > > > > pending that was not committed or rolled back) and then do the BEGIN. Of
> > > > > > course, if when we issue the commit if there is no pending transaction, we
> > > > > > get an error ... but that is trapped for and ignored if we are trying to
> > > > > > begin a new transaction.
> > > > > >
> > > > > > So, that said ... there should only be one transaction active for the
> > > > > > application at any given time and if by chance we try to start another one
> > > > > > the code automatically commits the first one before starting the 2nd one.
> > > > > >
> > > > > > Is there a way to query how many connections there are?
> > > > > > --
> > > > > > Brad Ashforth
> > > > > >
> > > > > >
> > > > > > "John Bell" wrote:
> > > > > >
> > > > > > > Hi Brad
> > > > > > >
> > > > > > > This looks like a XACT_E_CONNECTION_DENIED error, which might be thrown if
> > > > > > > you already have the maximum number of connections.
> > > > > > >
> > > > > > > John
> > > > > > >
> > > > > > > "Brad Ashforth" wrote:
> > > > > > >
> > > > > > > > A user has reported the message "A request to establish a connection with the
> > > > > > > > transaction manager was denied". The code is at this point attempting to
> > > > > > > > START a transaction. So far I have been unable to duplicate this, though the
> > > > > > > > user has been able to get through this code in the past. Of course, no known
> > > > > > > > changes.
> > > > > > > >
> > > > > > > > What causes this particular message?
> > > > > > > > --
> > > > > > > > Brad Ashforth

A Real Sql Server 2005 Bug! A Real Sql Server Bug!

A growing Sql Server 2005 database performs several hours of updates each
night. This particular region of code has run fine for over a year. Now we
are getting the folllowing message every few nights causing our processing to
abort:
Msg 8630, Level 17, State 52, Procedure sp_dts_post_activity, Line 150
Internal Query Processor Error: The query processor encountered an unexpected
error during execution.
This is a simplified version of the query from line 150:
select
p.PeriodStartDate,
p.PeriodType,
p.ActivityUserNumber,
p.AppNumber,
max( case when ActivityType = 'APP_SUBMITTED' then 1 else 0 end ),
max( case when ActivityType = 'DOCS_REVIEWED' then 1 else 0 end ),
max( case when ActivityType = 'DOCS_RECEIVED' then 1 else 0 end ),
max( case when ActivityType = 'DOCS_COMPLETED' then 1 else 0 end ),
max( case when ActivityType = 'BOOKED' then 1 else 0 end ),
max( case when ActivityType = 'FUNDED' then 1 else 0 end )
from Activity a, xxxPeriod p
where a.ActivityDate >= p.PeriodStartDate
and a.ActivityDate < p.PeriodEndDate
and a.ActivityUserNumber = p.ActivityUserNumber
and a.AppNumber = p.AppNumber
and ActivityType in (select code from Lookup where SetName =
'ACTIVITY_TYPE' and ParentCode = 'ACCOUNT')
group by p.PeriodStartDate, p.PeriodType, p.ActivityUserNumber, p.AppNumber
When this simplified query is run from the management studio, it fails about
10-20% of the time.
Some Observations:
- Sometimes we get a few records in the result set prior to the failure.
- This query works on our smaller development database.
- If we change the query in any of the following ways, the query works
(e.g., 15 attempts w/o an error):
- Removing the group by and max()
- Removing one or more max statements
- Hard-code the list of activity types in place of the sub-select from
Lookup table
Version:
Sql Server 2005, 9.00.2047.00,SP1, Standard Edition
Help!
Mike
Mike wrote:
> A growing Sql Server 2005 database performs several hours of updates each
> night. This particular region of code has run fine for over a year. Now we
> are getting the folllowing message every few nights causing our processing to
> abort:
> Msg 8630, Level 17, State 52, Procedure sp_dts_post_activity, Line 150
> Internal Query Processor Error: The query processor encountered an unexpected
> error during execution.
> This is a simplified version of the query from line 150:
> select
> p.PeriodStartDate,
> p.PeriodType,
> p.ActivityUserNumber,
> p.AppNumber,
> max( case when ActivityType = 'APP_SUBMITTED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_REVIEWED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_RECEIVED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_COMPLETED' then 1 else 0 end ),
> max( case when ActivityType = 'BOOKED' then 1 else 0 end ),
> max( case when ActivityType = 'FUNDED' then 1 else 0 end )
> from Activity a, xxxPeriod p
> where a.ActivityDate >= p.PeriodStartDate
> and a.ActivityDate < p.PeriodEndDate
> and a.ActivityUserNumber = p.ActivityUserNumber
> and a.AppNumber = p.AppNumber
> and ActivityType in (select code from Lookup where SetName =
> 'ACTIVITY_TYPE' and ParentCode = 'ACCOUNT')
> group by p.PeriodStartDate, p.PeriodType, p.ActivityUserNumber, p.AppNumber
> When this simplified query is run from the management studio, it fails about
> 10-20% of the time.
> Some Observations:
> - Sometimes we get a few records in the result set prior to the failure.
> - This query works on our smaller development database.
> - If we change the query in any of the following ways, the query works
> (e.g., 15 attempts w/o an error):
> - Removing the group by and max()
> - Removing one or more max statements
> - Hard-code the list of activity types in place of the sub-select from
> Lookup table
> Version:
> Sql Server 2005, 9.00.2047.00,SP1, Standard Edition
> Help!
> Mike
>
>
>
>
I would suspect a TEMPDB problem. Lack of space? Autogrow timeout?
Tracy McKibben
MCDBA
http://www.realsqlguy.com
|||Mike, please contact Microsoft product support.
Thanks,
Leo
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:168FB0C7-AF8D-4722-B8EF-FC5A8D309F47@.microsoft.com...
>A growing Sql Server 2005 database performs several hours of updates each
> night. This particular region of code has run fine for over a year. Now
> we
> are getting the folllowing message every few nights causing our processing
> to
> abort:
> Msg 8630, Level 17, State 52, Procedure sp_dts_post_activity, Line 150
> Internal Query Processor Error: The query processor encountered an
> unexpected
> error during execution.
> This is a simplified version of the query from line 150:
> select
> p.PeriodStartDate,
> p.PeriodType,
> p.ActivityUserNumber,
> p.AppNumber,
> max( case when ActivityType = 'APP_SUBMITTED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_REVIEWED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_RECEIVED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_COMPLETED' then 1 else 0 end ),
> max( case when ActivityType = 'BOOKED' then 1 else 0 end ),
> max( case when ActivityType = 'FUNDED' then 1 else 0 end )
> from Activity a, xxxPeriod p
> where a.ActivityDate >= p.PeriodStartDate
> and a.ActivityDate < p.PeriodEndDate
> and a.ActivityUserNumber = p.ActivityUserNumber
> and a.AppNumber = p.AppNumber
> and ActivityType in (select code from Lookup where SetName =
> 'ACTIVITY_TYPE' and ParentCode = 'ACCOUNT')
> group by p.PeriodStartDate, p.PeriodType, p.ActivityUserNumber,
> p.AppNumber
> When this simplified query is run from the management studio, it fails
> about
> 10-20% of the time.
> Some Observations:
> - Sometimes we get a few records in the result set prior to the failure.
> - This query works on our smaller development database.
> - If we change the query in any of the following ways, the query works
> (e.g., 15 attempts w/o an error):
> - Removing the group by and max()
> - Removing one or more max statements
> - Hard-code the list of activity types in place of the sub-select from
> Lookup table
> Version:
> Sql Server 2005, 9.00.2047.00,SP1, Standard Edition
> Help!
> Mike
>
>
>
>

A Real Sql Server 2005 Bug! A Real Sql Server Bug!

A growing Sql Server 2005 database performs several hours of updates each
night. This particular region of code has run fine for over a year. Now we
are getting the folllowing message every few nights causing our processing t
o
abort:
Msg 8630, Level 17, State 52, Procedure sp_dts_post_activity, Line 150
Internal Query Processor Error: The query processor encountered an unexpecte
d
error during execution.
This is a simplified version of the query from line 150:
select
p.PeriodStartDate,
p.PeriodType,
p.ActivityUserNumber,
p.AppNumber,
max( case when ActivityType = 'APP_SUBMITTED' then 1 else 0 end ),
max( case when ActivityType = 'DOCS_REVIEWED' then 1 else 0 end ),
max( case when ActivityType = 'DOCS_RECEIVED' then 1 else 0 end ),
max( case when ActivityType = 'DOCS_COMPLETED' then 1 else 0 end ),
max( case when ActivityType = 'BOOKED' then 1 else 0 end ),
max( case when ActivityType = 'FUNDED' then 1 else 0 end )
from Activity a, xxxPeriod p
where a.ActivityDate >= p.PeriodStartDate
and a.ActivityDate < p.PeriodEndDate
and a.ActivityUserNumber = p.ActivityUserNumber
and a.AppNumber = p.AppNumber
and ActivityType in (select code from Lookup where SetName =
'ACTIVITY_TYPE' and ParentCode = 'ACCOUNT')
group by p.PeriodStartDate, p.PeriodType, p.ActivityUserNumber, p.AppNumber
When this simplified query is run from the management studio, it fails about
10-20% of the time.
Some Observations:
- Sometimes we get a few records in the result set prior to the failure.
- This query works on our smaller development database.
- If we change the query in any of the following ways, the query works
(e.g., 15 attempts w/o an error):
- Removing the group by and max()
- Removing one or more max statements
- Hard-code the list of activity types in place of the sub-select from
Lookup table
Version:
Sql Server 2005, 9.00.2047.00,SP1, Standard Edition
Help!
MikeMike wrote:
> A growing Sql Server 2005 database performs several hours of updates each
> night. This particular region of code has run fine for over a year. Now
we
> are getting the folllowing message every few nights causing our processing
to
> abort:
> Msg 8630, Level 17, State 52, Procedure sp_dts_post_activity, Line 150
> Internal Query Processor Error: The query processor encountered an unexpec
ted
> error during execution.
> This is a simplified version of the query from line 150:
> select
> p.PeriodStartDate,
> p.PeriodType,
> p.ActivityUserNumber,
> p.AppNumber,
> max( case when ActivityType = 'APP_SUBMITTED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_REVIEWED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_RECEIVED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_COMPLETED' then 1 else 0 end ),
> max( case when ActivityType = 'BOOKED' then 1 else 0 end ),
> max( case when ActivityType = 'FUNDED' then 1 else 0 end )
> from Activity a, xxxPeriod p
> where a.ActivityDate >= p.PeriodStartDate
> and a.ActivityDate < p.PeriodEndDate
> and a.ActivityUserNumber = p.ActivityUserNumber
> and a.AppNumber = p.AppNumber
> and ActivityType in (select code from Lookup where SetName =
> 'ACTIVITY_TYPE' and ParentCode = 'ACCOUNT')
> group by p.PeriodStartDate, p.PeriodType, p.ActivityUserNumber, p.AppNumb
er
> When this simplified query is run from the management studio, it fails abo
ut
> 10-20% of the time.
> Some Observations:
> - Sometimes we get a few records in the result set prior to the failure.
> - This query works on our smaller development database.
> - If we change the query in any of the following ways, the query works
> (e.g., 15 attempts w/o an error):
> - Removing the group by and max()
> - Removing one or more max statements
> - Hard-code the list of activity types in place of the sub-select from
> Lookup table
> Version:
> Sql Server 2005, 9.00.2047.00,SP1, Standard Edition
> Help!
> Mike
>
>
>
>
I would suspect a TEMPDB problem. Lack of space? Autogrow timeout?
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||Mike, please contact Microsoft product support.
Thanks,
Leo
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:168FB0C7-AF8D-4722-B8EF-FC5A8D309F47@.microsoft.com...
>A growing Sql Server 2005 database performs several hours of updates each
> night. This particular region of code has run fine for over a year. Now
> we
> are getting the folllowing message every few nights causing our processing
> to
> abort:
> Msg 8630, Level 17, State 52, Procedure sp_dts_post_activity, Line 150
> Internal Query Processor Error: The query processor encountered an
> unexpected
> error during execution.
> This is a simplified version of the query from line 150:
> select
> p.PeriodStartDate,
> p.PeriodType,
> p.ActivityUserNumber,
> p.AppNumber,
> max( case when ActivityType = 'APP_SUBMITTED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_REVIEWED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_RECEIVED' then 1 else 0 end ),
> max( case when ActivityType = 'DOCS_COMPLETED' then 1 else 0 end ),
> max( case when ActivityType = 'BOOKED' then 1 else 0 end ),
> max( case when ActivityType = 'FUNDED' then 1 else 0 end )
> from Activity a, xxxPeriod p
> where a.ActivityDate >= p.PeriodStartDate
> and a.ActivityDate < p.PeriodEndDate
> and a.ActivityUserNumber = p.ActivityUserNumber
> and a.AppNumber = p.AppNumber
> and ActivityType in (select code from Lookup where SetName =
> 'ACTIVITY_TYPE' and ParentCode = 'ACCOUNT')
> group by p.PeriodStartDate, p.PeriodType, p.ActivityUserNumber,
> p.AppNumber
> When this simplified query is run from the management studio, it fails
> about
> 10-20% of the time.
> Some Observations:
> - Sometimes we get a few records in the result set prior to the failure.
> - This query works on our smaller development database.
> - If we change the query in any of the following ways, the query works
> (e.g., 15 attempts w/o an error):
> - Removing the group by and max()
> - Removing one or more max statements
> - Hard-code the list of activity types in place of the sub-select from
> Lookup table
> Version:
> Sql Server 2005, 9.00.2047.00,SP1, Standard Edition
> Help!
> Mike
>
>
>
>

Saturday, February 25, 2012

A question on Conversation timer persistence

I'd like to add code to a trigger to calculate the time to fire a message into a queue based on a field changing, and conversation timers seem like the way to go. My first question refers to this line from the BOL:

"Calling BEGIN CONVERSATION TIMER on a conversation before the timer has expired sets the timeout to the new value."

I think that in this trigger, I can simply begin a new conversation if the given field has changed to reset the timer. But intuition tells me that in order to change the timer to a new value, I need to retrieve the existing conversation, correct?

Also, I've read that conversation timers are persistent in that they survive database restarts and shutdowns. But I'm not sure to what extent. After a database restart/shutdown, does the conversation timer "reset" itself to the time interval specified when the conversation was begun or is it able to account for the time the database was down/offline?

Thanks,

Chris

I'm not sure I understand the requirements. Why is that you need to fire a timer as a result of a field change? The usual requirement is to fire a message so that some asynch processing happens later, but not based on a timer. Can you give some more details?

You can have only one timer per conversation. That what the BOL line refers to. You cannot have multiple timers, setting a new timer will erase the old one.

The timers are set as absolute time, not interval. After a database/server restart, if the time of the timer is in the past, then the timer will be fired.

HTH,
~ Remus

|||

Remus,

Thanks for the quick response.

Here's the workflow of the process: A user creates a work order for which they can assign a follow-up time. When this follow-up time arrives, I want to send a message to a Service Broker queue that I have already set up to process the message. If the follow-up time changes, the timer is adjusted to account for the change in time.

The only difference between what I need to do now and what I've already done is sending the message to the queue at a specific time. I imagined a trigger that would fire every time the follow-up time changed so that I could alter the conversation timer. This trigger would begin a new conversation, set a timer, and an activated stored procedure would look for the message type http://schemas.microsoft.com/SQL/ServiceBroker/DialogTimer and send a message to my original queue where it will be processed. I see 2 problems with my logic: I am looking for a DialogTimer message type, so the activated stored procedure only knows it is time to do something, but it has no message body that I can use to forward onto the final Service Broker queue. Also, I have no way of finding the conversation I started the last time the trigger fired.

I'm wondering if using a conversation timer is the wrong approach, and if so, what is?

Thanks,

Chris

|||

What you need is a table to associate the conversation which fired the timer with the original work order. When the work order is created, the trigger begin a dialog, sets the timer and then inserts into this table the newly created conversation handle and the work order id.

When the timer fires, the activated procedure receives the message, looks up the work order id in this table (based on the conversation handle the message was RECEIVE on) and does whatever work is required at that moment.

The same table can be also used when updates occur on the follow_up field. Instead of beginning a conversation, the trigger will look up this association table and find the existing conversation.

One thing to note is that timer messages are unlike any message in the sense that they are sent by one conversation endpoint to itself. So the conversation handle on which the timer was set is the same one as on which is going to be received.

I do believe that conversation timers are the right approach. No other approach I can think of is better. Conversation timers are very cheap from a resource point of view, completely contained within the database (this gives lots of advantages related to backup/restore, failover and availability), and offer the possibility to actually luch a procedure.

HTH,
~ Remus

|||

Thanks a lot Remus. A state table was what I came up with as well. I really appreciate being able to come here for valuable, practical advice on how to approach Service Broker issues. Thanks again,

Chris

A question about sqlxml

Who use sqlxml .net?

How can I write code like this:

select count(1) as count from Orders for xml auto

That's error.

And what is the correct sqlxml code?

Tks.

Hi,

the code works fine with SQL2005 but fails on SQL2K

Eralper

http://www.kodyaz.com

|||

You could write it like below for SQL Server 2000:

select count from (select count(1) as count from Orders) as Orders for xml auto

Saturday, February 11, 2012

A Gripe about Error Messages

[OLE DB Destination [255]] Error: The "input "OLE DB Destination Input" (268)" failed because error code 0xC020907B occurred, and the error row disposition on "input "OLE DB Destination Input" (268)" specifies failure on error. An error occurred on the specified object of the specified component.

I've condensed the useful information in the statement down to the following:

"An error occured."

I'd like to also provide a plain english paraphrase.

An error occured somewhere to something. This means that something somewhere didn't work right. The cause of the thing not working right is an error of some sort. We'd like to provide you with the following piece of diagnostic information: we know that an error occured somewhere to something because the error row disposition tells us this. We hope that helps. Thank you, and have a nice day.

Now, could anyone translate this into Klingon? I think it would be easier to understand and just as useful.

I agree with JO. Most of the SSIS error messages seem to be Vague and Unhelpful. It takes lot of time for a SSIS Dev to decipher the error messsages. The SSIS team should throw more meaningful and error messages that we all can understand and take action appropriately. Errors of the kind mentioned do not help in resolving the issues.

Thanks

AK

|||

Rename your components and look to the first error thrown from a given task for diagnostic/debugging purposes.

Leaving pipeline components at their default names makes debugging far harder. Renaming inputs and outputs is not usually done, because most components, provided they aren't sources, have a single input.

Jamie Thompson has a very useful naming convention , which if followed, will make that error message, and really, the ones which preceeded it, more meaningful, because the component name will not be the default. That doesn't make 0xC0... hex code any more meaningful, but I can tell you it does help.

Those creating somewhat permanent to permanent table names rarely leave the table at dbo.Table_1 because the name doesn't convey intent/purpose. Same concept goes for pipeline components, give them a meaningful name.

Was that the first error received? The first error is almost invariably the most helpful one, and its doubtful that was the first error thrown by the dataflow. Some of the first errors are still not as meaningful as I would like, but often this has to do with the provider, such as an OLEDB provider, which produces the messages which SSIS relays. Before imagining these are the words of an apologist, perhaps note my prior gripes about error messages as well.

Subsequent errors, particuarly in dataflows, are not as useful in debugging/diagnostics, because they are further and futher removed from the specificity and purpose of the component, and relate to how the pipeline works. Look (generally speaking) to the first error for any given task invocation.

Thursday, February 9, 2012

a function inside function in a query

The problem is the sum functions inside the effectivemass function, what should i do to fix it

Code Snippet

create view missEeCuts
AS
select e.idevent
from events e, isolatedLeptons as l, isolatedLeptons as l2
where dbo.module(e.PxMiss,e.PyMiss)>=40
and dbo.effectiveMass(e.PxMiss,e.PyMiss,sum(l.px)
,sum(l2.py))<= 150.0 and l2.eventid=e.idevent and l.eventid = e.idevent and l.idap <> l2.idap;

We need you to describe the problem or error in more detail please. I imagine you are getting a syntax or Group By -type error, but need to know more info.

Thanks,
Bryan

|||now i modified to this

Code Snippet

create view missEeCuts
AS
select e.idevent
from events as e, isolatedLeptons as l, isolatedLeptons as l2
where dbo.module(e.PxMiss,e.PyMiss)>=40
and l2.eventid=e.idevent and l.eventid = e.idevent and l.idap <> l2.idap
group by e.idevent
having dbo.effectiveMass(e.PxMiss,e.PyMiss,sum(l.px)
,sum(l2.py))<= 150.0;


and its trowing me this error

Msg 8121, Level 16, State 1, Procedure missEeCuts, Line 3
Column 'events.PxMiss' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8121, Level 16, State 1, Procedure missEeCuts, Line 3
Column 'events.PyMiss' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.

the thing is that i dont want to group by it by PxMiss, PyMiss
|||

I broke the code down a bit. Looking at hte logic, you might end up with a list of repeated idevent values so you may want to use a SELECT DISTINCT at the top. Still, this should take care of the GROUP BY issue

Code Snippet

create view missEeCuts
as
select
e.idevent
from events e
inner join (
select
eventid,
idap,
sum(px) as sum_px
from isolatedLeptons
group by
eventid,
idap
) l
on e.idevent=l.eventid
inner join (
select
eventid,
idap,
sum(py) as sum_py
from isolatedLeptsons
group by
eventid,
idap
) l2
on e.idevent=l2.eventid AND
l.idap <> l2.idap
where
dbo.module(e.PxMiss,e.PyMiss)>=40 AND
dbo.effectiveMass(e.PxMiss,e.PyMiss,l.sum_px),l2.sum_py))<= 150.0

|||now that one return me this error

Msg 3623, Level 16, State 1, Line 1
A domain error occurred.

the original one was this function and I need to change it to a view, returning a table with all the events that fullfil the condition

Code Snippet

create function missEeCuts
(@.idevent INT)
Returns bit
AS
BEGIN
declare @.pt31x Real;
declare @.pt31y Real;
set @.pt31x = (select sum(l.px)
from isolatedLeptons(@.idevent) as l);
set @.pt31y = (select sum(l2.py)
from isolatedLeptons(@.idevent) as l2);
return ( select distinct 1
from events e
where @.idevent= e.idevent and dbo.module(e.PxMiss,e.PyMiss)>=40
and dbo.effectiveMass(e.PxMiss,e.PyMiss,@.pt31x,@.pt31y)<= 150.0
)
END

GO

|||

There is most likely a mathematical error in there. Try running each of the subqueries independently to verify they work without errors. Also, verify the data type of the px and py fields are inline with the data types expected by the effectivemass function.

B.

|||youre right, the problem is in effectivemass