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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 7, 2014, 5:59 AM EDT
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.
Varsha B83 reputationPosted Apr 7, 2014, 10:21 PM EDT
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 7, 2014, 10:39 PM EDT
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.