Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Stairway to T-SQL DML Level 9: Adding Records to a table using INSERT Statement Expand / Collapse
Author
Message
Posted Thursday, January 19, 2012 5:38 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, June 6, 2014 2:06 PM
Points: 1,040, Visits: 277
Comments posted to this topic are about the item Stairway to T-SQL DML Level 9: Adding Records to a table using INSERT Statement

Gregory A. Larsen, MVP

Need SQL Server Examples check out my website at http://www.sqlserverexamples.com
Post #1238575
Posted Wednesday, September 5, 2012 7:19 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, July 24, 2014 7:43 AM
Points: 371, Visits: 954
I was unaware of the output option for this. I'm not sure I'll ever really need it but it is cool to know I have the option.

Cheers
Post #1354515
Posted Wednesday, September 5, 2012 9:48 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 1, 2014 3:27 PM
Points: 115, Visits: 957
Another useful variation of the INSERT command is the "SIF" format to create a table with fields based on the source table:

SELECT Id, Name, Quantity
INTO SomeOtherTable -- Or even @SomeOtherTable
FROM Fruit


This will create a table ("SomeOtherTable") with the Id, Name, and Quantity columns from the Fruit table. You can specify a WHERE clause to limit the records you pull out (WHERE Quantity > 2). Useful for on-the-fly requirements to get a subset of records out of a larger table to manipulate or scan through.
Post #1354696
Posted Monday, October 29, 2012 11:23 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 26, 2013 2:27 PM
Points: 9, Visits: 15
Why does the Id column in listing 9 start with 21 after the previous is dropped and the new one is made an identity?

Sorry... newbie here.
Post #1378379
Posted Monday, October 29, 2012 9:41 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, June 6, 2014 2:06 PM
Points: 1,040, Visits: 277
Very good question. Looks like the article output is incorrect. The id values should be 19 and 20. I'll will get this update. Thank you for pointing this out.

Greg


Gregory A. Larsen, MVP

Need SQL Server Examples check out my website at http://www.sqlserverexamples.com
Post #1378554
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse