Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Parse a string for a particular value

Posted on 2005-05-06
3
Medium Priority
?
239 Views
Last Modified: 2010-03-19
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
Comment
Question by:Lalitha_Ramalingam
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 500 total points
ID: 13947491
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
 

Author Comment

by:Lalitha_Ramalingam
ID: 13947611
Thanks a lot for your prompt reponse.  You saved my day.
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 13947654
ur wellcome mate

0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question