• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Parse a string for a particular value

Hello,

Urgent!!! I am trying to parse a string in SQL.  I have a column called remarks_text where the voucher number is mentioned.  I have to extract the records where the voucher_number column and the remarks_text column has the same voucher number mentioned.  Following is my query.  Appreciate if anybody could help me in this.

Thank you.

select LTrim(voucher.voucher_number) voucher_number,payments.remarks_text,voucher.voucher_reason, voucher.voucher_expiry, voucher.voucher_status,voucher.applied_book_no,voucher.payer_name,
       payments.payment_form,payments.payment_type,payments.payment_date,users.user_code,users.user_name,users.branch_codes
from voucher
Inner Join payments on voucher.applied_book_no = payments.book_no
Inner Join users on voucher.crea_user_code = users.user_code
where voucher.voucher_reason = 'GA'
and voucher.voucher_status = 'USED'
and voucher_expiry <= payment_date + 30
and charindex(LTrim('Voucher:'),payments.remarks_text)<>0

Lalitha
0
Lalitha_Ramalingam
Asked:
Lalitha_Ramalingam
  • 2
1 Solution
 
Melih SARICAOwnerCommented:
select LTrim(voucher.voucher_number) voucher_number,payments.remarks_text,voucher.voucher_reason, voucher.voucher_expiry, voucher.voucher_status,voucher.applied_book_no,voucher.payer_name,  payments.payment_form,payments.payment_type,payments.payment_date,users.user_code,users.user_name,users.branch_codes
from voucher
Inner Join payments on voucher.applied_book_no = payments.book_no
Inner Join users on voucher.crea_user_code = users.user_code
where voucher.voucher_reason = 'GA'
and voucher.voucher_status = 'USED'
and voucher_expiry <= payment_date + 30
and charindex(voucher.voucher_number,payments.remarks_text,1)<>0

Melih SARICA
0
 
Lalitha_RamalingamAuthor Commented:
Thanks a lot for your prompt reponse.  You saved my day.
0
 
Melih SARICAOwnerCommented:
ur wellcome mate

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now