Vi kan bruge GO [Count] til at køre batchen de gange, vi vil. For at indsætte poster i en tabel, der kun har identitetskolonne, kan vi også bruge GO-sætning med count.
USE TestDB GO DROP TABLE dbo.CustomerAddress GO CREATE TABLE dbo.CustomerAddress ( FName VARCHAR(100) ,LName VARCHAR(100) ,HouseNumber INT ,StreetName VARCHAR(100) ,City VARCHAR(100) ,[State] CHAR(2) ,IsActive BIT ) GO --Insert the same record ten times by using GO [count] INSERT INTO dbo.CustomerAddress VALUES ( 'Aamir' ,'Shahzad' ,123 ,'Test Street' ,'Charlotte' ,'NC' ,1 ) GO 10 CREATE TABLE dbo.CustomerT (id INT identity(1, 1)) GO --Insert 100 records into table that has only id as identity column by using GO [Count] INSERT INTO dbo.CustomerT DEFAULT VALUES GO 100
Videodemo :Brug GO Statement i SQL Server til at indsætte poster i Identity Column