What is the best way to pass a DataTable to a stored procedure?

I need to pass a DataTable to a stored procedure in MS SQL 2008 to insert multiple rows into a table at the same time. I came across methods that use XML documents to do this and even to pass lists as image data.

What is the best way to do this?

If necessary, provide sample code and / or links.

+3
source share
2 answers

- - , temp .

, , :

CREATE PROC DoStuff
AS BEGIN
    CREATE TABLE #tobeinserted (Data1 INT, Data2 INT...)
    EXEC InsertRows
END

CREATE PROC InsertRows
AS BEGIN
    INSERT INTO Table1 SELECT * FROM #tobeinserted
END

, , , . , , , () , . , SP.

+1

Source: https://habr.com/ru/post/1777034/


All Articles