sql - stored procedure parameters -
how can pass these 2 value combination separated and/ parameter value stored procedure:
"8033301552*" or "08033301552*"
or
"taiwo*" , "ayedun*"
i mean need create string , pass parameter?
officially not supported.
a workaround can found at
what doesn't work has nothing rs has stored procedures in sql server. cannot following in stored procedure. let's have parameter called @myparams can map parameter multi-value parameter if in stored procedure try this: select * sometable somefield in (@myparams) won't work. try it. create stored procedure , try pass multi-value parameter stored procedure. won't work. can have string parameter passed multivalue parameter , change string table. technique told me sql server mvp, erland sommarskog example have done inner join charlist_to_table(@sto,default)f on b.sto = f.str note not issue rs, strictly stored procedure issue. here function:
create function charlist_to_table (@list ntext, @delimiter nchar(1) = n',') returns @tbl table (listpos int identity(1, 1) not null, str varchar(4000), nstr nvarchar(2000)) begin declare @pos int, @textpos int, @chunklen smallint, @tmpstr nvarchar(4000), @leftover nvarchar(4000), @tmpval nvarchar(4000) set @textpos = 1 set @leftover = '' while @textpos <= datalength(@list) / 2 begin set @chunklen = 4000 - datalength(@leftover) / 2 set @tmpstr = @leftover + substring(@list, @textpos, @chunklen) set @textpos = @textpos + @chunklen set @pos = charindex(@delimiter, @tmpstr) while @pos > 0 begin set @tmpval = ltrim(rtrim(left(@tmpstr, @pos - 1))) insert @tbl (str, nstr) values(@tmpval, @tmpval) set @tmpstr = substring(@tmpstr, @pos + 1, len(@tmpstr)) set @pos = charindex(@delimiter, @tmpstr) end set @leftover = @tmpstr end insert @tbl(str, nstr) values (ltrim(rtrim(@leftover)), ltrim(rtrim(@leftover))) return end go
-- bruce loehle-conger mvp sql server reporting services "roland müller" wrote in message
Comments
Post a Comment