Identity Insert Statement

I have participated in several of the StackOverflow sites, and one of the things that I have noticed is that there is a real "bootstrap" problem in the beginning. There really needs to be a certain minimum number of active members with a minimum number of points before it really starts to work. In the interests of addressing this, (and unless the powers that be object) I will be posting challenge questions based on some of the older SqlServerCentral Questions Of The Day. The first answer which is correct will be marked as accepted (15 points). For the most part I will not be presenting the questions as multiple choice, as they originally were.

Identity Insert:

We have a table and it has just one column that the identity property of that column is set to ON, we need a query to insert some records in that, which of the following will work:

We have the following table:

CREATE TABLE TestID( ID int Identity(1,1))

What is the INSERT statement to insert records into this table?

more ▼

asked Oct 10, 2009 at 01:46 AM in Default

avatar image

782 6 9 12

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

more ▼

answered Oct 10, 2009 at 08:37 AM

avatar image

Matt Whitfield ♦♦
29.5k 62 66 88

Great Job, Matt! You've almost got enough points now to down-vote things (though I would recommend against that during this break-in period for the site, except the most awful stuff, spam, ads, etc.)

Oct 10, 2009 at 10:55 AM RBarryYoung

I thoroughly agree - I think it's going to be down to some of the SSC residents to build the site up, looking forward to it being more active :)

Oct 10, 2009 at 07:34 PM Matt Whitfield ♦♦
(comments are locked)
10|1200 characters needed characters left

May be worth mentioning that from SQL Server Management Studio (SSMS) you can add an integer after the GO command that inticates how many times to execute the batch. eg:

 GO 100

Will enter 100 rows into the table. No need to create a loop. And if you use Random numbers, GETDATE(), joins or similar functions you can rapidly build halfway decent load tables.

more ▼

answered Aug 07, 2010 at 05:32 PM

avatar image

David Lean

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 10, 2009 at 01:46 AM

Seen: 2037 times

Last Updated: Oct 11, 2009 at 06:13 AM

Copyright 2018 Redgate Software. Privacy Policy