September 26, 2012 at 9:41 pm
Comments posted to this topic are about the item IDENTITY INSERT
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
September 26, 2012 at 9:45 pm
September 26, 2012 at 11:01 pm
nice question ..
I remember someone asked me this question , I was quite confused and my guess was the default ..
apparently when I tested I did work..
thanks for the question..
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
September 27, 2012 at 1:11 am
Nice question
September 27, 2012 at 1:20 am
Great question.. I nearly fell into the trap of selecting answer two by not reading the question properly! Thanks.
September 27, 2012 at 3:01 am
Good question - thanks.
Glad I took time to have the 2nd coffee before answering though
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
September 27, 2012 at 3:03 am
Thanks for the nice, easy question :-). I say it easy because I have seen it many times, on SQLSkills.com. Paul Randal has used this (INSERT INTO TableName DEFAULT VALUES) in many of his excellent articles :cool:.
September 27, 2012 at 3:21 am
This was removed by the editor as SPAM
September 27, 2012 at 3:55 am
🙂 (...all that I had)
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 27, 2012 at 4:34 am
Thank you for the thought provoking (for me at least) question!
September 27, 2012 at 5:01 am
I still don't get it. What does he mean by "insert the value"? :ermm:
Best regards,
Andre Guerreiro Neto
Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2/MCSE/MCSA
September 27, 2012 at 5:13 am
Is it me, or does the "explanation" for (1) just repeat the incorrect syntax used in the question?
"IDENTITY_INSERT is used to set identity of a particular table. SET IDENTITY_INSERT ON/OFF "
September 27, 2012 at 5:23 am
Toreador (9/27/2012)
Is it me, or does the "explanation" for (1) just repeat the incorrect syntax used in the question?"IDENTITY_INSERT is used to set identity of a particular table. SET IDENTITY_INSERT ON/OFF "
I think the explanation is incomplete. The table name should be specified in the SET INDENTITY_INSERT tablename ON/OFF command.
September 27, 2012 at 6:05 am
1. Query 1 fails because there are no values provided to INSERT.
2. Query 2 fails because the syntax for SET IDENTITY_INSERT requires a table name.
3. Query 3 succeeds because DEFAULT VALUES instructs SQL Server to insert the identity vale.
4. Query 4 fails because VALUES (DEFAULT) does not work for identity columns.
The answer should have included a reference to INSERT (http://msdn.microsoft.com/en-us/library/aa933206(v=sql.80).aspx) for completeness to explain why 1 and 4 fail while 3 succeeds.
Otherwise, a pretty good question.
September 27, 2012 at 6:51 am
Thanks for that sknox and thanks for the great question. I nearly fell into the Identity Insert trap and was about to select it before I took a second look and realized what it was missing.
Viewing 15 posts - 1 through 15 (of 32 total)
You must be logged in to reply to this topic. Login to reply