December 20, 2007 at 2:02 pm
I have the following code:
SET @ConsultantID = '0017860'
SET @PeriodDate = '12/01/2007'
SET @AchieveLevel = 20
SET @Line='1,2'
SET @status = 'All' -- 'Inactive', 'All'
IF (@Status = 'Active')
SELECT * FROM #DLFiltered WHERE Active = 1
AND CurrentLevelXID >= @AchieveLevel
AND DownlineLevel IN (@Line)
ELSE IF (@Status = 'Inactive')
SELECT * FROM #DLfiltered WHERE Active = 0
AND CurrentLevelXID >= @AchieveLevel
AND DownlineLevel IN (@Line)
ELSE IF (@Status = 'All')
SELECT * FROM #DLfiltered WHERE Active In (1,0)
AND CurrentLevelXID >= @AchieveLevel
AND DownlineLevel IN (@Line)
Right now when I run this I get the following error:
Msg 245, Level 16, State 1, Line 148
Conversion failed when converting the varchar value '1,2' to data type int.
Which make sense but how would I convert the string of numbers into a string of Integer to be used in @Line?
Thanks
Thanks,
Art
Database Analyst
Tastefully Simple, Inc.
alorenzini@tastefullysimple.com
" Some days, it's not even worth chewing through the restraints!
December 20, 2007 at 2:17 pm
You could write a function that converts the string of numbers and returns a TABLE that contains the integers as values.
I think that is the easiest way to do and you can use again and again where ever you want it.
-Roy
December 20, 2007 at 2:29 pm
Do you have an example of one?
Thanks,
Art
Database Analyst
Tastefully Simple, Inc.
alorenzini@tastefullysimple.com
" Some days, it's not even worth chewing through the restraints!
December 20, 2007 at 2:44 pm
AND ',' + @Line + ',' LIKE '%,' + DownlineLevel + ',%'
N 56°04'39.16"
E 12°55'05.25"
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply