Question : Searching for a compairion with in a sentence T-sql

Hi there,
I have two tables i want to compaire.

The inforamtion in one table will be simialre to teh other based on
Customer id

However one table will hold notes.
Such as datetime, ''i recieved 150 today on payment''

on the other table it will show me
Customer id,
The date the payment was recieved (which will not be the same as the above date)
and the value recieved = 150

SO i want to be able to run a query that checks

The customer id = customer id
the date on the notes table is greater then the one on the other
but that the value in the payment table (150) will be contained somewheree with in the notes  table.

Is this possible.

For example

CREATE TABLE notes
(customer_id int,
date datetime,
notes  varchar(50)

INSERT INTO notes values (12,'2010-06-29 14:00:00','i recieved 150 today')

**ALL notes will not always have the same amount of text or type of text but they will always have a simalar value between the other table

CREATE TABLE PAYMENT
(id int,
date datetime,
value int)

INSERT INTO PAYMENT VALUES (12,'2010-06-30 11:00:00',150)
INSERT INTO PAYMENT VALUES (12,'2010-06-30 12:00:00',120)

Kind Regards,
Putoch

Answer : Searching for a compairion with in a sentence T-sql

oh my friend, you're using text datatype. That's not good. are you using SQL 2005? If so, then I urge you to change it to varchar(max) in order to avoid yourself lots of trouble in the future. If you're using SQL 2000, then definitively consider varchar(8000). In the mean time, we can try with "like" operator instead

1:
2:
3:
select a.* 
from payment a
inner join notesTEST b on a.id = b.CUSTOMER_id and dateadd(d, datediff(d, 0, a.[date]), 0) >= dateadd(d, datediff(d, 0, b.[date]), 0) and b.notes like '%' + cast(abs(A.value) as varchar) + '%'
Random Solutions  
 
programming4us programming4us