Showing posts with label accuracy. Show all posts
Showing posts with label accuracy. Show all posts

Tuesday, March 6, 2012

accuracy vs generalization

Hi!

So sorry for posting yet another one of my silly posts about the correct way of doing things!

I am using Stored Procedures to do various things in my database (inserting/deleting/updating) and using SQL Server 2000 SP4

The current situation is that I have a stored procedure which checks certain user details and returns either -1 or 1 as a success indicator to the caller.

Now, obviously if we executed several queries in this stored procedure, performance will be an issue.

However, I have no idea how to balance up the whole "more useful information" vs "general information". What I mean is this:

if we are checking 3 items in a table, I want to return the success value back to the caller - in this case, we could do an IF statement to see if the record exists, if it does, set the return value to 1, else, -1.

But then you may want to be more informative to the user, specifically stating what part of the information they entered is incorrect/invalid. So having this in mind, we would then need to execute, say, 3 queries to return a more specific "error" value.

What should I do in this case?

I want to check the username, password and if the account is activated.

Currently I have this query going on:

IF EXISTS (SELECT [ID] FROM Users WHERE username = @.un AND [password] = @.pw AND activate = 1)

SET @.theResult = 1

ELSE

SET @.theResult = -1

firstly, is that the good way of doing things? if not - then what is the better way?

secondly, if we decide that we want a specific detailed return value/error message, it would mean I have to check the results I want using a couple more queries, such as one query to check username, one query to check password and another to check if the account is active or not and then return the appropriate value back to the caller.

is this a good way of doing things? I am confused and stuck!

Many thanks for your valuable response :)

>>Now, obviously if we executed several queries in this stored procedure, performance will be an issue.<<

This isn't necessarily true, but it is always better to minimize the number of queries.

Take this query:

IF EXISTS (SELECT [ID] FROM Users WHERE username = @.un AND [password] = @.pw AND activate = 1)

SET @.theResult = 1

ELSE

SET @.theResult = -1

A better way to write this might be:

select ID, case when activate = 0 then 'inactive' else 'active' end as activeStatus,
case when password = @.pw then 'correct' else 'incorrect' end as pwCheck
from users
where username = @.un

Then, the caller can interpret the details as they see fit:

No result set - invalid user name, the other two possibilities are obvious.

|||Many thanks!

Accuracy of replicated data

Hi,
I use dial-up connection to replicate data between to servers. Our
replication type is Merge and I'm worried that what happens if the
connection fails when merge agent is working. Will the synchronization be
rolled back or I must necessarily use Transactional replication?
Thanks in advance,
Leila
"Leila" schrieb:

> Hi,
> I use dial-up connection to replicate data between to servers. Our
> replication type is Merge and I'm worried that what happens if the
> connection fails when merge agent is working. Will the synchronization be
> rolled back or I must necessarily use Transactional replication?
> Thanks in advance,
> Leila
Test it (it should be rolled back - and even if not: the next execution of
the merge agent should synchronize the publisher and subscriber again)!
If you you do not need bidirectional replication it is better to use
transactional replication anyway - it's faster and (unlike the merge
replication) guarantees the consistency of your data!
|||Thanks Christian,
But I'm trying to understand its logic without testing. Because my data are
important and sensitive and I cannot risk for testing!
"Christian Donner" <ChristianDonner@.discussions.microsoft.com> wrote in
message news:44A7E2F0-23EC-490E-82CD-820D15257830@.microsoft.com...[vbcol=seagreen]
> "Leila" schrieb:
be
> Test it (it should be rolled back - and even if not: the next execution of
> the merge agent should synchronize the publisher and subscriber again)!
> If you you do not need bidirectional replication it is better to use
> transactional replication anyway - it's faster and (unlike the merge
> replication) guarantees the consistency of your data!

Accuracy of Host column on SS 2000 Enterprise Manager Current Activity Process Info Screen

Yesterday and today, the Process Info screen in Enterprise Manager indicates that the "Host", a single workstation on our network, is generating around 50 connections to the database. This particular application is well-behaved and typically generates only 2 to 5 connections per instance. Furthermore, we cannot find this particular workstation/host on our network because we retired it off the network some time ago.

Anyone know of the accuracy of the Hosts column on this Enterprise Manager screen? We're suspecting that the network address column is correct but the Hosts column is incorrect. There are about 10 different network addresses pertaining to this particular Host (1-5 connections per network address).

Can you check the mAC Address for that host and find on the network?|||I have also been having that problem. I was able to use the MAC address to track down the PC when I first saw the problem, but found that the computer name was not what was displayed in SQL EM. Additionally, I am continuing to have the same problem but have found that different MAC addresses are being listed all with the same Host name. Should you find more information regarding this issue please post your results here.

Accuracy of Host column on SS 2000 Enterprise Manager Current Activity Process Info Screen

Yesterday and today, the Process Info screen in Enterprise Manager indicates that the "Host", a single workstation on our network, is generating around 50 connections to the database. This particular application is well-behaved and typically generates only 2 to 5 connections per instance. Furthermore, we cannot find this particular workstation/host on our network because we retired it off the network some time ago.

Anyone know of the accuracy of the Hosts column on this Enterprise Manager screen? We're suspecting that the network address column is correct but the Hosts column is incorrect. There are about 10 different network addresses pertaining to this particular Host (1-5 connections per network address).

Can you check the mAC Address for that host and find on the network?|||I have also been having that problem. I was able to use the MAC address to track down the PC when I first saw the problem, but found that the computer name was not what was displayed in SQL EM. Additionally, I am continuing to have the same problem but have found that different MAC addresses are being listed all with the same Host name. Should you find more information regarding this issue please post your results here.