SQL Server Performance
  1. venkatesanj@hcl.in New Member

    I got a peculiar doubt.... rather its a simple one too. How to insert records in the bleow table,
    create
    table Venkattemp (id int identity(1,1))
    Thanks and Regards,
    Venkatesan Prabu .J
    http://venkattechnicalblog.blogspot.com/
  2. Adriaan New Member

    Identity columns - why do want to insert any specific value into them?
    If you must, you could do something along there lines:set
    identity_insert mytable on
    insert into mytable (identitycolumn) values (your integer value)
    set identity_insert mytable off
    This is your second question on identity columns where you simply don't know the proper syntax - please look stuff up in Books Online before posting.
  3. Madhivanan Moderator

    [quote user="Adriaan"]
    Identity columns - why do want to insert any specific value into them?
    If you must, you could do something along there lines:set
    identity_insert mytable on
    insert into mytable (identitycolumn) values (your integer value)
    set identity_insert mytable offThis is your second question on identity columns where you simply don't know the proper syntax - please look stuff up in Books Online before posting.
    [/quote]
    Another way to populate it in the actual order is
    insert into Venkattemp default values
    I have seen this approach to populate a number table. You just need a loop to execute that code
  4. preethi Member

    [quote user="Madhivanan"]I have seen this approach to populate a number table. You just need a loop to execute that code[/quote]
    Or you can specify the number after GO statement too.
    Eg..
    insert into Venkattemp default values;
    GO 10

  5. Madhivanan Moderator

    [quote user="preethi"]
    [quote user="Madhivanan"]I have seen this approach to populate a number table. You just need a loop to execute that code[/quote]
    Or you can specify the number after GO statement too.
    Eg..
    insert into Venkattemp default values;
    GO 10

    [/quote]
    Yes provided the version is later than 2000
  6. FrankKalis Moderator

    [quote user="Madhivanan"]
    [quote user="preethi"]
    [quote user="Madhivanan"]I have seen this approach to populate a number table. You just need a loop to execute that code[/quote]
    Or you can specify the number after GO statement too.
    Eg..
    insert into Venkattemp default values;
    GO 10

    [/quote]
    Yes provided the version is later than 2000
    [/quote]
    Hm, this question was asked in the "SQL Server 2008" forums.... [;)]
  7. Madhivanan Moderator

    <P mce_keep="true">[quote user="FrankKalis"] <P>[quote user="Madhivanan"]</P><P>[quote user="preethi"] </P><P>&nbsp;[quote user="Madhivanan"]I have seen this approach to populate a number table. You just need a loop to execute that code[/quote]</P><P>Or you can specify the number after GO statement too.</P><P>Eg..&nbsp; </P><P><FONT color=#0000ff size=2><FONT color=#000000 size=2>insert into Venkattemp default values; </FONT></FONT></P><P><FONT color=#0000ff size=2><FONT color=#000000 size=2>GO 10 <BR></FONT></FONT></P><P>[/quote]</P><P>Yes provided the version is later than 2000</P><P>[/quote]&nbsp;</P><P>Hm, this question was asked in the "SQL Server 2008" forums.... <IMG alt=Wink src="http://sql-server-performance.com/Community/emoticons/emotion-5.gif" mce_src="http://sql-server-performance.com/Community/emoticons/emotion-5.gif"> <BR></P><P>[/quote]</P><P>Thanks [:)]</P><P>But I think it is worth to specify it [;)]</P>
  8. Adriaan New Member

    Sorry for my bad temper earlier on on this thread ...
    I learned something new (GO 10) ...
    and was reminded of something I do not regret forgetting (INSERT INTO table DEFAULT VALUES)
  9. venkatesanj@hcl.in New Member

    Thanks to all. I have learnt something today.
    Cheers,
    Venkatesan Prabu .J
  10. Madhivanan Moderator

  11. Madhivanan Moderator

  12. FrankKalis Moderator

    [quote user="Madhivanan"]
    [quote user="Adriaan"]
    Sorry for my bad temper earlier on on this thread ...
    I learned something new (GO 10) ...
    and was reminded of something I do not regret forgetting (INSERT INTO table DEFAULT VALUES)
    [/quote]
    You may need to read these
    http://sqlblogcasts.com/blogs/madhivanan/archive/tags/GO/default.aspx
    [/quote]
    What a shameless plug this is...[:D]
  13. Madhivanan Moderator

    <P mce_keep="true">[quote user="FrankKalis"] <P>[quote user="Madhivanan"]</P><P>[quote user="Adriaan"] </P><P>Sorry for my bad temper earlier on on this thread ...</P><P>I learned something new (<STRONG>GO 10</STRONG>) ...</P><P>and&nbsp;was reminded of something I&nbsp;do not regret forgetting&nbsp;(<STRONG>INSERT INTO&nbsp;</STRONG><EM>table </EM><STRONG>DEFAULT VALUES</STRONG>)</P><P>[/quote]</P><P>You may need to read these </P><P><A href="http://sqlblogcasts.com/blogs/madhivanan/archive/tags/GO/default.aspx">http://sqlblogcasts.com/blogs/madhivanan/archive/tags/GO/default.aspx</A></P><P mce_keep="true">&nbsp;</P><P>[/quote]&nbsp;</P><P>What a shameless plug this is...<IMG alt="Big Smile" src="http://sql-server-performance.com/Community/emoticons/emotion-2.gif"> <BR></P><P>[/quote]</P><P>Adriaan specified the thing G0 10 was new to him so as my reply [;)]</P>
  14. FrankKalis Moderator

    [quote user="venkatesanj@hcl.in"]
    I got a peculiar doubt.... rather its a simple one too. How to insert records in the bleow table,
    create table Venkattemp (id int identity(1,1))
    [/quote]
    Looking at the table name, it may be a good idea to have a permanent number helper table. [:)]

Share This Page