hi,
How to pass an array to SQL SERVER 2008 stored procedure and update all the values of array into a table...?
not insert only update
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Apr 8, 2014, 2:39 AM
hi,
Try...
CREATE TYPE dbo.TableValuedTypeExample AS TABLE
(
Id INT NOT NULL
)
GO
CREATE PROC TestStoreProc
(@TempTable AS dbo.TableValuedTypeExample READONLY)
AS
BEGIN
Declare @Id int
Declare MYdata CURSOR FOR
Select Id from @TempTable
OPEN MYdata
FETCH NEXT FROM MYdata INTO @Id
WHILE @@FETCH_STATUS = 0
BEGIN
--Write your logic
print @Id
FETCH NEXT FROM MYdata INTO @Id
END
CLOSE MYdata
DEALLOCATE MYdata
END
-- code for test your store procedure in query window
declare @p as dbo.TableValuedTypeExample
insert into @p values (1)
insert into @p values (2)
insert into @p values (3)
exec TestStoreProc @p
hope this will help you.
Varsha BPosted Apr 8, 2014, 2:21 AM
Thanks
Jignesh TrivediPosted Apr 7, 2014, 9:59 AM
hi,
Table value parameter can help you to achieve this...
Please refer my article
http://www.c-sharpcorner.com/UploadFile/ff2f08/table-value-parameter-use-with-C-Sharp/
hope this will help you.