-2

Like inserting single or multiple records at a time, one table data is inserting into another table with limited columns.

Swamy
  • 19
  • 6

2 Answers2

2

There are (at least) four ways:

  • INSERT. Pretty obvious. It supports both single rows and multiple rows supplied as literal values, as well as inserting the result of a query or stored procedure.
  • SELECT .. INTO inserts the results of a query into a new table.
  • BULK INSERT. Bulk inserts data from files. It's a little quirky and not very flexible when it comes to parsing files, but if you can get the data to line up it works well enough. Selecting data for bulk insert purposes can also be done with OPENROWSET(BULK, ...).
  • INSERT BULK. This is an internal command that's used under the covers by drivers that use the bulk insert protocol in TDS (the protocol used by SQL Server). You do not issue these commands yourself. Unlike BULK INSERT, this is for client-side initiated bulk inserting, for example through the SqlBulkCopy class in .NET, or SQL Server's own bcp tool.

All other interfaces and approaches to inserting data use one of these methods under the covers. Most of these will use plain old INSERT.

Jeroen Mostert
  • 27,176
  • 2
  • 52
  • 85