use a string by reference?
-
I think there should be a way to do this. In the calling program, I have a list of numbers that I'm building in an sql statement so that the statement looks like this:
"SELECT firstname FROM tblPerson WHERE personid in (9,2,4)"
that works fine, but I need to use this as a stored procedure now and I need to be able to send in "(9,2,4)" as parameter. Is there a way I can make the sql use the string by reference as regular sql like this:SELECT firstname FROM tblPerson WHERE personid in @idlist
where @idlist is a varchar string that I passed in from my app? My articles BlackDice -
I think there should be a way to do this. In the calling program, I have a list of numbers that I'm building in an sql statement so that the statement looks like this:
"SELECT firstname FROM tblPerson WHERE personid in (9,2,4)"
that works fine, but I need to use this as a stored procedure now and I need to be able to send in "(9,2,4)" as parameter. Is there a way I can make the sql use the string by reference as regular sql like this:SELECT firstname FROM tblPerson WHERE personid in @idlist
where @idlist is a varchar string that I passed in from my app? My articles BlackDiceNevermind. I got it to work. i just turned the whole sql statement into a string, saved it to a variable and called exec() on the variable My articles BlackDice
-
I think there should be a way to do this. In the calling program, I have a list of numbers that I'm building in an sql statement so that the statement looks like this:
"SELECT firstname FROM tblPerson WHERE personid in (9,2,4)"
that works fine, but I need to use this as a stored procedure now and I need to be able to send in "(9,2,4)" as parameter. Is there a way I can make the sql use the string by reference as regular sql like this:SELECT firstname FROM tblPerson WHERE personid in @idlist
where @idlist is a varchar string that I passed in from my app? My articles BlackDiceBlack Dice, You can create a sql Server function that takes a delimited list as a parameter and returns a table. then in your select list you join onto this function SELECT firstname, lastname FROM employee e INNER JOIN fn_MyFUnction(@DelimitedList) f On e.ID = F.ID "Never Code by Coincidence" -- Andy Hunt