| ||
To | Do This |
---|---|
Create an INSERT statement in SQL Server Management Studio | Right-click the desired table. Select Script Table As Select Insert To Choose the desired destination. |
Insert a blank row | Ensure that you have default values for all of the columns . Execute INSERT INTO < Table_Name > DEFAULT VALUES. |
Insert values from another table | Execute INSERT INTO < Table_Name > (< columnlist >) SELECT < Matching_column_List > from < Source_Table_name >. |
Insert values using views | Ensure that you are only inserting values for columns in a single table. |
Insert values using views to more than one table | Implement an INSTEAD OF trigger on the view to insert the values in the different tables appropriately. |
Import data from files | Use the BCP utility. Use Integration Services to fine-tune your import process. |
Enhance control and security in insert operations | Encapsulate the insert commands in stored procedures. |
Perform other actions while inserting data | Implement an AFTER trigger on the table. |
Control errors during database actions | Use TRY CATCH blocks to obtain information from the ERROR_x functions. |
Insert data from an ADO.NET application | Use the ADO.NET Connection and Command objects. |
| ||