| ParasDalal 2005-05-20, 8:59 pm |
| You will need a SQL stored procedure that will give you the comma separated
values as recordset. And then you can use the "IN" clause. Try using the
following function:
CREATE FUNCTION BT_FN_GetResultSetFromStringList
(@csvString varchar(8000))
RETURNS @CsvResults TABLE (csvcode varchar(4000))AS
BEGIN
DECLARE @off int
DECLARE @substr varchar(4000)
DECLARE @nextValue varchar(4000)
DECLARE @prevOff int
SELECT @prevOff = 1
SELECT @off = CHARINDEX(',', @csvString, 0)
WHILE (@off > 0)
BEGIN
SELECT @nextValue = RTRIM(SUBSTRING(@csvString, @prevOff, @off-@prevOff))
SELECT @prevOff = @off+1
insert into @CsvResults (csvcode) Values (@nextValue)
SELECT @off = CHARINDEX(',', @csvString, @prevoff)
END
if (LEN(@csvString)-@prevOff+1 > 0)
BEGIN
-- if string did not terminate with a trailing comma
SELECT @nextValue = RTRIM(SUBSTRING(@csvString, @prevOff,
LEN(@csvString)-@prevOff+1))
insert into @CsvResults (csvcode) Values (@nextValue)
END
return
END
GO
When you use the function, it will be like:
ststack_cod in (select * from BT_FN_GetResultSetFromStringList(@StkLis
t))
"javad.ebrahimnezhad" wrote:
> i used cr9.2 in my vb project
>
> i used a proceuder with input parameter
>
> when i test storeproceuder with input parameter it is true
> when i used procedur in report in cr9.2 enviroment it is true
>
> but when i pass input parameter from vb project it doesnt work and i have an
> error in procedure text
>
>
> exec .STARTCYCL2P '1,2'
>
> ALTER proc dbo.STARTCYCL2P @stklist as nvarchar(3000)
> as
>
> exec ('
> select * from ststackt where ststack_cod in (' + @stklist +')
>
> ')
>
>
> thx
>
>
>
>
|