bustercoder
Programmer
- Mar 13, 2007
- 96
Hello,
This select is used to populate a drop-down in a report, showing the cust# and name concatenated and is used as an input parameter for a stored proc:
SELECT DISTINCT [CUSTOMER] = LTRIM(RTRIM(RM00101.CUSTNMBR)) + ' - ' + LTRIM(RTRIM(RM00101.CUSTNAME))
FROM RM00101
WHERE RM00101.CUSTNAME <> ''
So, I am trying to take everything to the right of the dash and use that as the input parameter, as shown in this excerpt from my stored proc:
@customer varchar(50)
SELECT
RM30201.CUSTNMBR,
RM30201.APFRDCNM
FROM
RM30201 INNER JOIN RM00101 ON RM30201.CUSTNMBR = RM00101.CUSTNMBR
WHERE
RM00101.CUSTNAME = {{STRING FN(@customer)}}
I was playing around with PATINDEX, SUBSTRING, RIGHT, different SQL functions, but can't seem to get it right. If someone could show me I would sure appreciate it. It would be a good learning exercise for future.
Thanks,
Buster
This select is used to populate a drop-down in a report, showing the cust# and name concatenated and is used as an input parameter for a stored proc:
SELECT DISTINCT [CUSTOMER] = LTRIM(RTRIM(RM00101.CUSTNMBR)) + ' - ' + LTRIM(RTRIM(RM00101.CUSTNAME))
FROM RM00101
WHERE RM00101.CUSTNAME <> ''
So, I am trying to take everything to the right of the dash and use that as the input parameter, as shown in this excerpt from my stored proc:
@customer varchar(50)
SELECT
RM30201.CUSTNMBR,
RM30201.APFRDCNM
FROM
RM30201 INNER JOIN RM00101 ON RM30201.CUSTNMBR = RM00101.CUSTNMBR
WHERE
RM00101.CUSTNAME = {{STRING FN(@customer)}}
I was playing around with PATINDEX, SUBSTRING, RIGHT, different SQL functions, but can't seem to get it right. If someone could show me I would sure appreciate it. It would be a good learning exercise for future.
Thanks,
Buster