CrystalDuck
Programmer
I've found numerous posts on the site that has very similar questions to mine...but nothing quite "on the money". So I thought I would post the code I am using and see what I'm doing wrong.
All I get back is a dataset for the #Dealer_Number_Search that looks like this:
Dealer_Number
------------------
1 0000015
2
3
4
5
6
Here's the code that make this happen. What step am I missing?
Also...
is there a way to do this when you don't know the length of the parameter value? For example...
@Dealer_No= '0000015,000019,022,0055707,5714,00557'
Thank you for any help you can provide.
Thank you,
CrystalDuck
![[ponytails2] [ponytails2] [ponytails2]](/data/assets/smilies/ponytails2.gif)
All I get back is a dataset for the #Dealer_Number_Search that looks like this:
Dealer_Number
------------------
1 0000015
2
3
4
5
6
Here's the code that make this happen. What step am I missing?
Code:
CREATE TABLE #DEALER_Number_Search (
Dealer_Number char(7))
Declare @Dealer_number VARCHAR(100),
@len int,
@start int
SET @Dealer_Number='0000015,0000019,0000022,0055707,0055714,0055715'
--parse the Dealer Numbers
IF @Dealer_Number IS NOT NULL
BEGIN
SET @start = 1
SELECT @len = LEN(LTRIM(RTRIM(@Dealer_Number)))
WHILE @start <= @len
BEGIN
SELECT @Dealer_Number = SUBSTRING(@Dealer_Number, @start,7)
INSERT #DEALER_Number_Search VALUES (@Dealer_Number)
SELECT @start = @start + 8
END
END
Select * from #DEALER_Number_Search
Also...
is there a way to do this when you don't know the length of the parameter value? For example...
@Dealer_No= '0000015,000019,022,0055707,5714,00557'
Thank you for any help you can provide.
Thank you,
CrystalDuck
![[ponytails2] [ponytails2] [ponytails2]](/data/assets/smilies/ponytails2.gif)