Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Passing an Array parameter to a stored procdure

Author  Topic 

anouar114
Starting Member

1 Post

Posted - 2009-08-04 : 05:26:25
Hello,

How can i pass an array paramter to a stored procedure.
I tryed to passed nvarchar but i cant retrieve the different values.

This my stored procedure:

CREATE PROCEDURE [dbo].[usp_client_Filter]
@client nvarchar(64)= N'%%',
@clientValues nvarchar(64),
AS
BEGIN

SELECT [SocieteLib], [ClientID], [ClientLib]

FROM MyDatabase

WHERE
( (([ClientLib] Like @client) or ([ClientLib] in (@clientValues)) or ([ClientLib] is null)))
END

Merci en avance

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-04 : 05:28:42
Search for Array+SQL Server in google/bing

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Disco Patrick
Starting Member

18 Posts

Posted - 2009-08-04 : 06:31:14
You can achieve array-like functionality by passing an variable of type XML to the stored proc.

You have to generate the XML file first of course. You can do this using C# / .NET if thats the language you're using for the front end.

Then once the XML has been passed to the proc, you can access it using the OPENXML keyword in SQL.

If you search my previous posts, you'll find a discussion about this.
Go to Top of Page

rocknpop
Posting Yak Master

201 Posts

Posted - 2009-08-04 : 06:56:11
Maybe you can even look at the xml data type in sql 2005

--------------------
Rock n Roll with SQL
Go to Top of Page
   

- Advertisement -