Is there any way passing array data types from/to a stored procedure?
Please reply. Thanks in advance.
Regards,
Hyun-jik BaeBae
SQL Server does not supprt arrays but you can do something like that
CREATE PROCEDURE array_sp
@.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 array_sp
@.array = '''sysobjects'',''sysindexes'',''syscolu
mns'''
GO
"Bae,Hyun-jik" <imays@.NOSPAM.paran.com> wrote in message
news:%23pxpkj8TFHA.1796@.TK2MSFTNGP15.phx.gbl...
> Is there any way passing array data types from/to a stored procedure?
> Please reply. Thanks in advance.
> Regards,
> Hyun-jik Bae
>|||Passing Arrays:
http://vyaskn.tripod.com/passing_ar..._procedures.htm
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Uri Dimant" <urid@.iscar.co.il> schrieb im Newsbeitrag
news:uqnPwu8TFHA.2520@.TK2MSFTNGP09.phx.gbl...
> Bae
> SQL Server does not supprt arrays but you can do something like that
> CREATE PROCEDURE array_sp
> @.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 array_sp
> @.array = '''sysobjects'',''sysindexes'',''syscolu
mns'''
> GO
> "Bae,Hyun-jik" <imays@.NOSPAM.paran.com> wrote in message
> news:%23pxpkj8TFHA.1796@.TK2MSFTNGP15.phx.gbl...
>|||http://www.sommarskog.se/arrays-in-sql.html
Jacco Schalkwijk
SQL Server MVP
"Bae,Hyun-jik" <imays@.NOSPAM.paran.com> wrote in message
news:%23pxpkj8TFHA.1796@.TK2MSFTNGP15.phx.gbl...
> Is there any way passing array data types from/to a stored procedure?
> Please reply. Thanks in advance.
> Regards,
> Hyun-jik Bae
>|||SQL has one data structure, the table. There are not arrays. You can
kludge it with strings that hold CSV. It is slow, procedural and
cannot guarantee data integrity. The right way is to load the data into
a table and start thinking in terms of SQL solutions instead of your
previous programming languages.
No comments:
Post a Comment