显示标签为“event”的博文。显示所有博文
显示标签为“event”的博文。显示所有博文

2012年3月22日星期四

anynone seen this error

Hello,
Does anyone seen this error before?
I've searched through the web, books online, and googles groups. NOTHING.
Event ID 17052, Category 2
Error 50501, severity 16
State 1
DBE_add_event: Invalid taskbinder (taskbinder id=0, rows=0)
This event occurs very often, like each 4-5 minutes....
ThanksIs this error from SQL Server as source? If so, then it is a user-defined error (as it has > 50000
as error number). I suggest you check this with your application vendor.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Dany" <dany_langlois@.yahoo.com> wrote in message
news:4080a045.0312160725.2f6df8db@.posting.google.com...
> Hello,
> Does anyone seen this error before?
> I've searched through the web, books online, and googles groups. NOTHING.
>
> Event ID 17052, Category 2
> Error 50501, severity 16
> State 1
> DBE_add_event: Invalid taskbinder (taskbinder id=0, rows=0)
>
> This event occurs very often, like each 4-5 minutes....
> Thankssql

2012年2月23日星期四

Any Ideas? SQL teaser

A little SQL problem I'm having –
I want to update the MaxInd and MinInd columns of a table to indicate which
rows have minimum or maximum event date for a given URN.
It is important that only one record per URN be marked as the Maximum or
Minimum but it is possible that a single event may be both the maximum AND
the minimum
This problem is quite simple to solve if event dates are all unique;
problems start to occur when multiple minimum or maximum dates exist in this
list
Consider the table below which for the moment has no ‘problem’ entries
Tables
Event
ID URN EventDate MaxInd MinInd
-- -- -- -- --
1 1 01/01/2006 N Y
2 1 03/03/2006 Y N
3 1 02/01/2006 N N
4 2 08/01/2006 Y N
5 2 03/01/2006 N N
6 3 08/01/2006 Y Y
Values for the MaxInd and MinInd columns where supplied using the following
update
UPDATE Event
SET
MaxInd = CASE WHEN EventDate = Ranges.MaxDate THEN 1 ELSE 0 END,
MinInd = CASE WHEN EventDate = Ranges.MaxDate THEN 1 ELSE 0 END
FROM (
SELECT MAX(EventDate) AS MaxDate, MIN(EventDate) AS MinDate, URN
FROM Event
GROUP BY URN
) AS Ranges
WHERE Event.URN = Ranges.URN
Now lets update the Event table to introduce some problem events and the
values for MaxInd and MinInd I would like –
ID URN EventDate MaxInd MinInd Notes
-- -- -- -- -- --
1 1 01/01/2006 N Y
2 1 03/03/2006 Y N
3 1 02/01/2006 N N
4 2 08/01/2006 Y N
5 2 03/01/2006 N N
6 3 08/01/2006 Y Y
7 1 01/01/2006 N N Same event date
as ID 1
8 2 08/01/2006 N N Same event date
as ID 4
9 3 08/01/2006 N N Same event date
as ID 6
When using the SQL presented above, this data scenario will result in the
three new records being marked with a MaxInd or MinInd in addition to their
related events also being marked as MinInd or MaxInd.
This situate breaks the rule that only one event per URN can be either the
Maximum or MinimumStephen wrote:
> This situate breaks the rule that only one event per URN can be either the
> Maximum or Minimum
... and therefore your requirements specification is incomplete. You
said you only want to update one row but you haven't told us which one
it should be. SQL isn't good at stuff like "Give me any one row. I
don't care which". Even if it were easier solve, code that returns
random results tends to look like a bug to end users and testers. For
that reason, you should always query an ambiguity like this one by
going back to the user, business owner or whoever.
Also, please post a CREATE TABLE statement for the table. That way we
don't have to guess what the actual datatypes and constraints are and
we can test out possible solutions for you. Don't forget to include
keys. Presumably you do have some keys to work with? I don't like to
make too many assumptions without seeing the table structure but on the
face of it the table design looks weak. I'd suggest you eliminate the
duplicate data rather than write lots of complex code to cope with it.
Finally, do tell us what version of SQL Server you are using.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Also, the maximum and minimum should be functions of the data in your table,
and not stored as data themselves. They are results of a query and should
be determined when you need to access them, not stored and physically
updated. Of course this is a rule of database design, and sometimes there
are reasons (i.e. performance) for breaking these rules. Usually, however,
you can follow the rules and still get good performance, if you are careful
with how you write your SQL queries and how you index your columns.
You should consider either creating a unique constraint that prevents these
duplicate dates, or adding a sequence column to differentiate them.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1143818532.404505.236730@.i40g2000cwc.googlegroups.com...
> Stephen wrote:
the
> ... and therefore your requirements specification is incomplete. You
> said you only want to update one row but you haven't told us which one
> it should be. SQL isn't good at stuff like "Give me any one row. I
> don't care which". Even if it were easier solve, code that returns
> random results tends to look like a bug to end users and testers. For
> that reason, you should always query an ambiguity like this one by
> going back to the user, business owner or whoever.
> Also, please post a CREATE TABLE statement for the table. That way we
> don't have to guess what the actual datatypes and constraints are and
> we can test out possible solutions for you. Don't forget to include
> keys. Presumably you do have some keys to work with? I don't like to
> make too many assumptions without seeing the table structure but on the
> face of it the table design looks weak. I'd suggest you eliminate the
> duplicate data rather than write lots of complex code to cope with it.
> Finally, do tell us what version of SQL Server you are using.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>

2012年2月18日星期六

Any help on application that works like a profiler

Hi
I like to write an application that works kind of like Profiler.
I want to get some sort of event notification that something has happened on
the database server to let me know I should check for data and then log into
some table.
I tried through system stored procedure, but they don't let me directly
trace into the table, for that I have trace into file then from there to a
table.
I want to write something like profiler type application, that should be
continously listening to server events.
Are there any COM objects available for that or some other where through
which I can do this.
Thanks in Advance
PushkarIn SQL Server profiler, you can filter events based on application name or
user, and output the event trace to a table or text file. Once this is in
place, your application can simply query for specific event conditions. Just
in case, if your intention is to implement a complex data constraint, then
use a trigger. Also, if you are wanting to block specific types of user
access to tables or stored procedures, then implement this using appropriate
logins and object level permissions.
"Pushkar" <tiwaripushkar@.yahoo.co.in> wrote in message
news:eFI1SsgZFHA.2520@.TK2MSFTNGP09.phx.gbl...
> Hi
> I like to write an application that works kind of like Profiler.
> I want to get some sort of event notification that something has happened
on
> the database server to let me know I should check for data and then log
into
> some table.
> I tried through system stored procedure, but they don't let me directly
> trace into the table, for that I have trace into file then from there to a
> table.
> I want to write something like profiler type application, that should be
> continously listening to server events.
> Are there any COM objects available for that or some other where through
> which I can do this.
> Thanks in Advance
> Pushkar
>

2012年2月13日星期一

Any alternative way to retreive data

Hi: Guys
Given the table below I want a select query that returns the AccountRepID with the largest single sale for each RegionID. In the event of a tie choose any single top AccountRepID to return.

CREATE TABLE [Sales] (
[SalesID] [int] IDENTITY (1, 1) NOT NULL ,
RegionID] [int],
[AccountRepID] [int],
[SalesAmount] [money]
)

If the data were
salesid,regionid,accountrepid,salesamount
1,101,31,$50
2,101,32,$25
3,102,31,$25
4,102,32,$25
5,102,31,$15

The query should return
regionid,accountrepid
101,31
102,31 or 102,32

Is there another way to get the data other than the following query:

select regionID,accountrepid FROM Sales
where salesamount in
(select max(salesamount) FROM Sales group by regionid)

ThanksI don't think that will actually get you what you need. What if one region has the exact same salesamount as another region, but it's not the max for that region. You've then returned duplicate rows for that region.

Try this:

SELECT sa1.regionID, MAX(sa1.accountrepid)
FROM
Sales sa1
INNER JOIN (
SELECT regionID, MAX(salesamount) AS salesamount
FROM Sales) sa2 ON sa1.regionID = sa2.regionID
AND sa1.salesamount = sa2.salesamount|||select a.RegionId,a.AccountRepId,a.SalesAmount From Sales a
Inner join
(select RegionId,Max(salesAmount) as SalesAmount from Sales group by RegionId) b
on a.RegionId = b.RegionId and a.SalesAmount = b.SalesAmount