Thursday, March 22, 2012

Accessing array elements in the stored procedure

Hi All,
I want to pass a string array to a stored procedure.
Can anybody suggest a way to access the elements of the array in the stored
procedure?
Thanks
kdhttp://vyaskn.tripod.com/passing_ar..._procedures.htm
HTH, Jens Suessmeyer.
"kd" <kd@.discussions.microsoft.com> schrieb im Newsbeitrag
news:185EF2EB-394D-4943-B487-89D6AA3775BA@.microsoft.com...
> Hi All,
> I want to pass a string array to a stored procedure.
> Can anybody suggest a way to access the elements of the array in the
> stored
> procedure?
> Thanks
> kd|||kd
One of many is
CREATE PROCEDURE sparray_method_1
@.array nvarchar(4000)
AS
BEGIN
SET NOCOUNT ON
DECLARE @.nsql nvarchar(4000)
SET @.nsql = '
SELECT *
FROM sysobjects
WHERE name IN ( ' + @.array + ')'
PRINT @.nsql
EXEC sp_executesql @.nsql
END
GO
EXEC sparray_method_1
@.array = '''sysobjects'',''sysindexes'',''syscolu
mns'''
GO
"kd" <kd@.discussions.microsoft.com> wrote in message
news:185EF2EB-394D-4943-B487-89D6AA3775BA@.microsoft.com...
> Hi All,
> I want to pass a string array to a stored procedure.
> Can anybody suggest a way to access the elements of the array in the
stored
> procedure?
> Thanks
> kd|||http://www.sommarskog.se/arrays-in-sql.html
Jacco Schalkwijk
SQL Server MVP
"kd" <kd@.discussions.microsoft.com> wrote in message
news:185EF2EB-394D-4943-B487-89D6AA3775BA@.microsoft.com...
> Hi All,
> I want to pass a string array to a stored procedure.
> Can anybody suggest a way to access the elements of the array in the
> stored
> procedure?
> Thanks
> kd

No comments:

Post a Comment