|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 5:38 AM
Points: 344,
Visits: 601
|
|
Hi all,
I've been trying to find a way to do set-based inserts into a SQL Server.
As near as I can tell, there are only 2 ways: 1) convert the data to be inserted to XML, pass that SQL Server, either a sproc or a file; 2) export to file and BULK INSERT in SQL Server.
Neither of these are especially appealing.
Is there not something equivalent to $Table.Insert($NewData)
Save-IntoSQLTable appears to be on the right track, but also seems to want only to work with traces.
Any ideas?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 10:19 PM
Points: 6,704,
Visits: 11,736
|
|
Anything you can do in .NET you can do in PoSH. Lookup Table-valued Parameters, and how to use them to insert sets of data using one in a Stored Procedure. Most if not all of the examples will be in C# or VB.net, but like I said, you can port that code to PoSH. TVPs or the .NET class SqlBulkCopy are the two best ways I know of to insert batches of data from memory directly into SQL Server. If you write the data to disk that opens up all the bulk load methods of course, like bcp, BULK INSERT, SSIS, etc.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 5:38 AM
Points: 344,
Visits: 601
|
|
Oooooohhh. Me like TVP! 
Thanks opc!
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, April 19, 2013 10:29 AM
Points: 156,
Visits: 732
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 5:38 AM
Points: 344,
Visits: 601
|
|
Thanks Laerte!
Found you a couple of months ago, I appreciate your work.
I also found these functions last week.
P
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, April 19, 2013 10:29 AM
Points: 156,
Visits: 732
|
|
|
|
|