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)
 Array object

Author  Topic 

companionz
Yak Posting Veteran

54 Posts

Posted - 2009-10-05 : 06:53:55
Hello,

I need to create a procedure which will take an array as input. Has anyone created any such proc ?

We can do the same in Oracle but how to do that in SQL server?

Thanks,
Sourav

smarty
Starting Member

13 Posts

Posted - 2009-10-05 : 09:54:11
You could use XML as the input and convert that back to a table using OPENXML
For reference http://msdn.microsoft.com/en-us/library/ms187367.aspx

Example
DECLARE @InputXML AS NVARCHAR(MAX)
DECLARE @hDoc INT
SET @InputXML = '<XPATH><Node>value</Node><Node>value2</Node></XPATH>'
EXEC sp_xml_preparedocument @hDoc OUTPUT, @InputXML
SELECT * FROM OPENXML(@hDoc, '/XPATH/Node') WITH (NodeNAme VARCHAR(300) '.')
EXEC sp_xml_removedocument @hDoc



-----------------------------------
Free SQL server monitoring for DBA's
www.realsmartsoftware.co.uk
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-10-05 : 10:49:35
What version of SQL Server?

I believe version 2008 has this ability now...I'm stuck on 2k5 for the moment



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

smarty
Starting Member

13 Posts

Posted - 2009-10-05 : 10:56:50
quote:
Originally posted by X002548

What version of SQL Server?

I believe version 2008 has this ability now...I'm stuck on 2k5 for the moment




Correct - You can have table valued parameters in SQL2008

-----------------------------------
Free SQL server monitoring for DBA's
www.realsmartsoftware.co.uk
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-10-05 : 14:06:45
quote:
Originally posted by companionz

Hello,

I need to create a procedure which will take an array as input. Has anyone created any such proc ?

We can do the same in Oracle but how to do that in SQL server?

Thanks,
Sourav



http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm
Go to Top of Page
   

- Advertisement -