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 12»»

Identity Columns Expand / Collapse
Author
Message
Posted Saturday, July 5, 2008 11:05 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, June 25, 2014 9:48 AM
Points: 52, Visits: 275
Comments posted to this topic are about the item Identity Columns

Susantha
Post #528874
Posted Sunday, July 6, 2008 5:36 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, June 25, 2014 9:26 PM
Points: 2,953, Visits: 436
Good question, I never thought default values can be used for inserting identity value, I always thought it is meant to be for inserting default value only. I learn something new everyday here :D


Urbis, an urban transformation company
Post #528997
Posted Monday, July 7, 2008 1:54 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, July 10, 2014 12:43 AM
Points: 217, Visits: 170
Proof that you can teach an old dog some new tricks, probably depends on the willingness to learn though... thanks for the question
Post #529102
Posted Monday, July 7, 2008 6:51 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, May 19, 2014 1:46 AM
Points: 1,033, Visits: 139
I thought that the statement should be INSERT INTO ..., but nobody complains about the missing INTO, so I start doubting: can it work without?
Post #529230
Posted Monday, July 7, 2008 7:21 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, June 26, 2014 6:11 AM
Points: 1,330, Visits: 815
Joseph (7/7/2008)
I thought that the statement should be INSERT INTO ..., but nobody complains about the missing INTO, so I start doubting: can it work without?


INTO is an optional keyword. I always use it for readability purposes but it does work without.
Post #529274
Posted Monday, July 7, 2008 8:00 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, July 10, 2014 12:43 AM
Points: 217, Visits: 170
I can concur on the optional "into", but if memory serves me correctly, if you specify the columns to be inserted, one has to include the "into", or is it still optional even specifying columns?
Post #529324
Posted Monday, July 7, 2008 8:07 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:45 PM
Points: 23,081, Visits: 31,620
From BOL regarding the INSERT statement:


INTO
Is an optional keyword that can be used between INSERT and the target table.





Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #529333
Posted Monday, July 7, 2008 8:10 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, July 10, 2014 12:43 AM
Points: 217, Visits: 170
that means irrespective of anything, the "into" is optional.
Post #529337
Posted Monday, July 7, 2008 8:29 AM
SSC-Enthusiastic

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

Group: General Forum Members
Last Login: Monday, March 31, 2014 3:38 AM
Points: 124, Visits: 120
Here is an alternative solution without 'set identity_insert' ;)

INSERT INTO TEST WITH (KEEPIDENTITY) (Col1)
SELECT IDENT_CURRENT('Test') FROM OPENROWSET(BULK N'C:\boot.ini', SINGLE_BLOB) AS a


Post #529359
Posted Monday, July 7, 2008 10:13 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, September 16, 2010 3:52 AM
Points: 78, Visits: 55
Dariusz Czechowicz (7/7/2008)
Here is an alternative solution without 'set identity_insert' ;)

INSERT INTO TEST WITH (KEEPIDENTITY) (Col1)
SELECT IDENT_CURRENT('Test') FROM OPENROWSET(BULK N'C:\boot.ini', SINGLE_BLOB) AS a




We allways have the hard way to do something!
Post #529449
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse