Glowworm27
Programmer
Hello all,
I am having a re-occuring problem.
I am trying to retrieve some customer information, last, first, middle names, address, city, state zip. etc.
from our customer database, I have it inner joined on the invoice table so I can check if the customer spent more than 50 bucks.
The problem I am having is that I am removing records if the firstname is null, or blank, and using the patindex , I am removeing them if the firstname has any numbers, or non-alpha characters in the first position. (i am also doing the same checks on the lastname field as well.
The error I keep getting is "Transaction (Process ID 70) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction."
IF I comment out the 2 patindex WHERE statements the SQL executes no problem. but I still have a few records with non-alpha characters in the first positions of the lastname or firstname.
Any idea on how to prevent the deadlock, or is there a better way to filter out records where the fields lastname or firstname have non-alpha characters in them?
here is the sql I am trying to execute
Thanks in advance
![[cannon] [cannon] [cannon]](/data/assets/smilies/cannon.gif)
I can't program for the Unknown, I have A keyboard not a Ouija Board. (See an online ouija board at George Oakes
Check out this awsome .Net Resource!
I am having a re-occuring problem.
I am trying to retrieve some customer information, last, first, middle names, address, city, state zip. etc.
from our customer database, I have it inner joined on the invoice table so I can check if the customer spent more than 50 bucks.
The problem I am having is that I am removing records if the firstname is null, or blank, and using the patindex , I am removeing them if the firstname has any numbers, or non-alpha characters in the first position. (i am also doing the same checks on the lastname field as well.
The error I keep getting is "Transaction (Process ID 70) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction."
IF I comment out the 2 patindex WHERE statements the SQL executes no problem. but I still have a few records with non-alpha characters in the first positions of the lastname or firstname.
Any idea on how to prevent the deadlock, or is there a better way to filter out records where the fields lastname or firstname have non-alpha characters in them?
here is the sql I am trying to execute
Code:
SELECT DISTINCT
Invoices.CustomerID, Customers.FirstName, Customers.LastName, Customers.Add1, Customers.Add2, Customers.City, Customers.State,
Customers.Zip
FROM Invoices INNER JOIN
Customers ON Invoices.CustomerID = Customers.ID INNER JOIN
Payments ON Invoices.ID = Payments.InvID
WHERE (Invoices.Storeno = 0857)
AND (Invoices.Trandate BETWEEN '01/01/2002' AND '03/31/2004')
And patindex('%[!-9]%',Customers.firstname) <> 1
And patindex('%[!-9]%',Customers.lastname) <> 1
AND (ISNULL(Customers.FirstName, '') <> '')
AND (LEN(Customers.FirstName) > 1)
AND (ISNULL(Customers.LastName, '') <> '')
AND (LEN(Customers.LastName) > 2)
AND (ISNULL(Customers.Add1, '') <> '')
AND (LEN(Customers.Add1) > 7)
AND (ISNULL(Customers.Add1, '') <> '')
AND (ISNULL(Customers.City, '') <> '')
AND (ISNULL(Customers.State, '') <> '')
AND (ISNULL(Customers.Zip, '') <> '')
AND (Payments.PayAmt > 49.99)
Thanks in advance
![[cannon] [cannon] [cannon]](/data/assets/smilies/cannon.gif)
I can't program for the Unknown, I have A keyboard not a Ouija Board. (See an online ouija board at George Oakes
Check out this awsome .Net Resource!