Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

GO statment

Mar 3 2013 12:00AM by Deepak kelath   

Today i studied an interesting thing related to GO statment

See in the following queries executed .The batch preceding GO will execute the specified number of times.

create table test( id  int not null identity (1, 1) primary key)
go

insert into test default values;
go 1000
Read More..   [32134 clicks]

Published under: SQL Server Tips · TSQL Tips ·  ·  · 


Deepak kelath
213 · 1% · 222
10
 
2
 
11
 
0
Incorrect
 
0
Interesting
 
0
Forgotten



Submit

15  Comments  

  • Hi Deepak,

    Really fantastic tip........

    NOTE: Question-- HOW TO INSERT A DATA INTO A TABLE WHICH IS HAVING A ONLY ONE COLUMN WITH IDENTITY PROPERTY.Ans-- Your Query only.

    Thanks for sharing your thoughts.

    commented on Mar 3 2013 9:46AM
    Bala Krishna
    84 · 2% · 676
  • Although I actually like this tip, I didn't mark it as such because you don't remind people that GO doesn't work in a stored procedure.

    commented on Mar 3 2013 3:07PM
    Jeff Moden
    161 · 1% · 306
  • @Bala wrote

    NOTE: Question-- HOW TO INSERT A DATA INTO A TABLE WHICH IS HAVING A ONLY ONE COLUMN WITH IDENTITY PROPERTY.Ans-- Your Query only.

    Any bets on that? You'll also find that method of populating a single column table to be one of the slowest there is.

    Here's one method that will create and populate the table with a million rows in a little less time than the other code takes to do only 1000 rows. That means the following code is more than a 1000 times faster. ;-)

     SELECT TOP 1000000
            N = IDENTITY(INT,1,1)
       INTO #Test
       FROM sys.all_columns ac1
      CROSS JOIN sys.all_columns ac2
    ;
    
    commented on Mar 3 2013 3:18PM
    Jeff Moden
    161 · 1% · 306
  • Hi Jeff Moden,

    Thanks for your reply.

    I am not talking about any performance wise with deepak's query.This would also be a answer for the question(WHICH I MENTIONED IN MY NOTE).

    Any How thanks for your reply.

    commented on Mar 4 2013 12:27AM
    Bala Krishna
    84 · 2% · 676
  • Thanks bala

    commented on Mar 4 2013 1:24AM
    Deepak kelath
    213 · 1% · 222
  • Thanks jeff for the point i forget to mention

    commented on Mar 4 2013 1:28AM
    Deepak kelath
    213 · 1% · 222
  • Bala wrote: I am not talking about any performance wise with deepak's query.This would also be a answer for the question(WHICH I MENTIONED IN MY NOTE).

    I know you're not talking "about any performance wise". That's why I did. ;-) Performance is pretty bad for such a thing and I wanted others to know. I also wanted them to know that, contrary to what you stated, there's more than one way to insert data into a single column table with the IDENTITY property. No disrespect meant... just stating the facts.

    commented on Mar 4 2013 6:47PM
    Jeff Moden
    161 · 1% · 306
  • Hi Moden,

    Agree with you.

    Thanks for your valuable comment..

    commented on Mar 4 2013 11:37PM
    Bala Krishna
    84 · 2% · 676
  • NOTE: Question-- HOW TO INSERT A DATA INTO A TABLE WHICH IS HAVING A ONLY ONE COLUMN WITH IDENTITY PROPERTY.Ans-- Your Query only.

    Try this

    CREATE TABLE Identity_Test ( A INT IDENTITY(1,100) ) GO

    INSERT Identity_Test DEFAULT VALUES

    SELECT * FROM Identity_Test

    DROP TABLE Identity_Test

    Thanks Vinay Kumar http://growwithsql.blogspot.in/

    commented on Mar 13 2013 2:55AM
    Vinay Kumar
    664 · 0% · 51
  • Vinay...

    I must be missing something here. That's the same as the original post except it only does 1 row.

    commented on Mar 13 2013 6:20PM
    Jeff Moden
    161 · 1% · 306
  • Hi Jeff,

    if you want to insert more rows, then execute below T-sql

    CREATE TABLE Identity_Test ( A INT IDENTITY(1,100) ) GO

    INSERT Identity_Test DEFAULT VALUES GO 1000

    SELECT * FROM Identity_Test GO

    DROP TABLE Identity_Test GO

    Vinay Kumar

    commented on Mar 14 2013 12:22AM
    Vinay Kumar
    664 · 0% · 51
  • @Vinay,

    It looks like you may not have read the rest of this thread. Please see the original post and my response to using the "GO" separator for such a thing.

    commented on Mar 14 2013 2:56PM
    Jeff Moden
    161 · 1% · 306
  • @vinay,

    Thanks for your comment.

    commented on Mar 15 2013 1:35AM
    Bala Krishna
    84 · 2% · 676
  • nice tip

    commented on Aug 30 2013 3:19AM
    Anilvanjre
    261 · 1% · 171
  • Awesome

    commented on May 29 2014 6:20AM
    PRIT0783
    2916 · 0% · 3

Your Comment


Sign Up or Login to post a comment.

"GO statment " rated 5 out of 5 by 10 readers
GO statment , 5.0 out of 5 based on 10 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]