Puzzle question in SQL Server


 
I have tried to execute the query and got a different result,
 

CREATE TABLE VENKAT_TABLE (ID INT IDENTITY(1,1))

INSERT INTO VENKAT_TABLE DEFAULT VALUES
GO 100
 
Detailed steps:  
   1. Created table
   2. Insert records in the table with default values
   3. Execute the statement for 100 times.  
Oops.. One record inserted and for second am getting the error as.... the table is already exists.  
Reason,  
    The "GO" statement is considering both the statements above it and it's trying to create the table and insert the record into it.  
 

      CREATE TABLE VENKAT_TABLE (ID INT IDENTITY(1,1))

      GO  -- Should have seperate GO here.
      INSERT INTO VENKAT_TABLE DEFAULT VALUES
      GO 100

Cheers,


Venkatesan Prabu .J
Head - WWW.Kaashivinfotech.com
http://venkattechnicalblog.blogspot.com/
Ebook Download
View all
Learn
View all